Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message pack marshaller/custom fomatters #240

Merged
merged 4 commits into from
Sep 28, 2024

Conversation

max-ieremenko
Copy link
Owner

@max-ieremenko max-ieremenko commented Sep 28, 2024

ServiceModel.Grpc.MessagePackMarshaller should support AOT builds.

dotnet publish some-project.csproj
<PropertyGroup>
  <TargetFramework>net8.0</TargetFramework>
  <PublishAot>true</PublishAot>
</PropertyGroup>

<ItemGroup>
  <PackageReference Include="ServiceModel.Grpc.MessagePackMarshaller" />
</ItemGroup>
[MessagePackObject]
class SomeObject {}

[OperationContract]
Task<SomeObject> PingPong(SomeObject value);

IL code-generation is not the case, all required code should be generated during the build time. Extend ServiceModel.Grpc.DesignTime and ServiceModel.Grpc.MessagePackMarshaller to support MessagePack custom formaters.

<ItemGroup>
   <!-- reference c# code generators -->
  <PackageReference Include="ServiceModel.Grpc.DesignTime" />
</ItemGroup>
[ImportGrpcService(typeof(IService))] // instruct ServiceModel.Grpc.DesignTime to generate required code during the build process
[MessagePackDesignTimeExtension]  // instruct ServiceModel.Grpc.MessagePackMarshaller to generate required code during the build process
internal static partial class MyGrpcServices {}

Behind the scene required custom formaters should be created and registered for use with MessagePackMarshallerFactory

@max-ieremenko max-ieremenko changed the title Message pack marshaller/cusom fomatters Message pack marshaller/custom fomatters Sep 28, 2024
@max-ieremenko max-ieremenko merged commit 56c6f8f into release/1.9.1 Sep 28, 2024
4 checks passed
@max-ieremenko max-ieremenko deleted the MessagePackMarshaller/cusom-fomatters branch September 28, 2024 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant