Skip to content

Releases: Cysharp/MagicOnion

6.1.6

06 Nov 06:17
Compare
Choose a tag to compare

What's Changed

Other Changes

Full Changelog: 6.1.5...6.1.6

6.1.5

16 Oct 09:15
Compare
Choose a tag to compare

What's Changed

Other Changes

  • Introduce PublicApiAnalyzers to Client, Abstractions and Shared by @mayuki in #818
  • Use NullabilityInfoContext to replace Type's nullable detection in release 6.x by @SmRiley in #855

New Contributors

Full Changelog: 6.1.4...6.1.5

6.1.4

17 Jul 07:51
Compare
Choose a tag to compare

What's Changed

Other Changes

  • Use Profiler API with PerformanceTest by @mayuki in #773
  • Fix internal errors when IsReturnExceptionStackTraceInErrorDetail is enabled by @mayuki in #809

Full Changelog: 6.1.3...6.1.4

6.1.3

08 May 07:10
Compare
Choose a tag to compare

What's Changed

Fixes

  • Update MemoryPack to 1.21.1 by @mayuki in #764
  • Fix method signature of MemoryPackFormatter for UNITY_2021_3_OR_NEWER by @0x5143 in #757

Housekeeping

New Contributors

Full Changelog: 6.1.2...6.1.3

6.1.2

22 Mar 05:51
Compare
Choose a tag to compare

What's Changed

  • Update pre-built Source Generator for Unity

Full Changelog: 6.1.1...6.1.2

6.1.1

21 Mar 09:28
0c2c69c
Compare
Choose a tag to compare

What's Changed

Breaking Changes

  • [Preview] OnRequestBegin/OnRequestEnd -> OnMethodInvoke by @mayuki in #750

Other Changes

Full Changelog: 6.1.0...6.1.1

6.1.0

21 Mar 06:37
ef6f04a
Compare
Choose a tag to compare

Features

Add StreamingHub OnConnected support by @riversdark0 in #745

Introduced the event OnConnected after a connection is established with a client on the server's StreamingHub.

This differs from OnConnecting in that the client is notified that the connection is complete and can then communicate via Broadcast.

Allow DynamicArgumentTuple as a reference type on Unity in #747

This PR allows DynamicArgumentTuple as a reference type on Unity.

Unity IL2CPP builds often have issues with the code size due to generics and value types.
MAGICONION_USE_REFTYPE_DYNAMICARGUMENTTUPLE build constant allows DynamicArgumentTuple to be treated as a reference type.

[Preview] Introduce IStreamingHubDiagnosticHandler in #746

This PR introduces an API for diagnosing and tracing the communication of StreamingHub. The API is in preview and may be subject to change in the future.

This API only supports the Source Generator at this moment and you need to set the EnableStreamingHubDiagnosticHandler option to true in the generation options. By setting this option, the StreamingHubDiagnosticHandler property will be added to the generated class, allowing you to set a handler.

namespace MagicOnion.Client;

/// <summary>
/// [Preview] The interface of the handler for StreamingHub diagnostics. This API may change in the future.
/// </summary>
public interface IStreamingHubDiagnosticHandler
{
    /// <summary>
    /// The callback method at the beginning of a Hub method request. This API may change in the future.
    /// </summary>
    void OnRequestBegin<THub, TRequest>(THub hubInstance, Guid requestId, string methodName, TRequest request, bool isFireAndForget);

    /// <summary>
    /// [Preview] The callback method at the end of a Hub method request. This API may change in the future.
    /// </summary>
    void OnRequestEnd<THub, TResponse>(THub hubInstance, Guid requestId, string methodName, TResponse response);

    /// <summary>
    /// [Preview] The callback method when a method of HubReceiver is invoked. This API may change in the future.
    /// </summary>
    void OnBroadcastEvent<THub, T>(THub hubInstance, string methodName, T value);
}

What's Changed

Breaking Changes

  • Move GenerateSerializerType into MagicOnionClientGenerationAttribute by @mayuki in #748

Other Changes

  • Update how share project in Unity by @neuecc in #733
  • Mark GrpcChannelProvider(GrpcChannelOptions) as Obsolete by @mayuki in #734
  • ci: Cysharp/Actions/.github/workflows/create-release.yaml by @guitarrapc in #737
  • ci: remove Ver. prefix for release by @guitarrapc in #744

New Contributors

Full Changelog: 6.0.1...6.1.0

6.0.1

12 Jan 01:50
e222779
Compare
Choose a tag to compare

Note

This release is only for Unity users.

What's Changed

Fixes

Full Changelog: 6.0.0...6.0.1

6.0.0

11 Jan 10:26
Compare
Choose a tag to compare

Highlights

MagicOnion.Client.SourceGenerator in #688

This release introduces a source generator for platform that require pre-generated client code (e.g. Unity, NativeAOT, MAUI ...).
The source generator also replaces MagicOnion.Generator (moc).

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.

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

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.

For example, if the MyApp.Shared assembly contains MyApp.Shared.Services.IGreeterService and MyApp.Shared.Hubs.IChatHub, specify one of them.

using MagicOnion.Client;

[MagicOnionClientGeneration(typeof(MyApp.Shared.Services.IGreeterService))]
partial class MagicOnionGeneratedClientInitializer {}

Next, configure MessagePack to use the generated MessagePack Resolver. This is the same as when using the legacy MagicOnion.Generator.

#if UNITY_2019_4_OR_NEWER
[UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.BeforeSceneLoad)]
#elif NET5_0_OR_GREATER
[System.Runtime.CompilerServices.ModuleInitializer]
#endif
static void RegisterResolvers()
{
    StaticCompositeResolver.Instance.Register(
        // Add: Use MessagePack formatter resolver generated by the source generator.
        MagicOnionGeneratedClientInitializer.Resolver,
        MessagePack.Resolvers.GeneratedResolver.Instance,
        BuiltinResolver.Instance,
        PrimitiveObjectResolver.Instance
    );

    MessagePackSerializer.DefaultOptions = MessagePackSerializer.DefaultOptions
        .WithResolver(StaticCompositeResolver.Instance);
}

Source generation options

You can specify options in the named constructor of the attribute.

  • 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.

Breaking changes

MagicOnion.Generator (moc) has been removed. The legacy generator is no longer supported.

Warning

While there is currently compatibility between MagicOnion.Client and MagicOnion.Generator (moc), there is no guarantee that this will be maintained.

Introduce ServiceContext.SetRawBytesResponse in #677

This PR introduces ServiceContext.SetRawBytesResponse method.

This method allows you to set raw byte sequences as a response. This makes it possible to send a cached response body without serialization.

public override async ValueTask Invoke(ServiceContext context, Func<ServiceContext, ValueTask> next)
{
    if (ResponseBytesCache.TryGetValue(context.CallContext.Method, out var cachedBytes))
    {
        context.SetRawBytesResponse(cachedBytes);
        return;
    }

    await next(context);

    ResponseBytesCache[context.CallContext.Method] = MessagePackSerializer.Serialize(context.Result);
}

Note

The raw byte sequence must be serialized as a MessagePack (or custom serialization) format. MagicOnion will write a byte requence directly into the response buffer.

Add StreamingHub metrics in #716

This release introduces metrics related to StreamingHub using System.Diagnostics.Metrics.

Meter: MagicOnion.Server

Metric Unit Tags
magiconion.server.streaminghub.connections {connection} rpc.system, rpc.service
magiconion.server.streaminghub.method_duration ms rpc.system, rpc.service, rpc.method
magiconion.server.streaminghub.method_completed {request} rpc.system, rpc.service, rpc.method, magiconion.streaminghub.is_error
magiconion.server.streaminghub.exceptions {exception} rpc.system, rpc.service, rpc.method, error.type

Tags

Tag name Value
rpc.system magiconion
rpc.service StreamingHub interface name (e.g. IGreeterService)
rpc.method StreamingHub method name (e.g. HelloAsync)
magiconion.streaminghub.is_error Whether a StreamingHub method call succeeded or failed. (e.g. true or false)
error.type Thrown exception type (e.g. System.InvalidOperationException)

Breaking Changes

Use Grpc.Net.Client by default on Unity in #704

This release changes the default gRPC library in Unity to grpc-dotnet.
From this release, the recommended gRPC library combination is YetAnotherHttpHandler and grpc-dotnet.

However, at this time, we are still supporting C-core. If you continue to use the C-core gRPC library, please define USE_GRPC_CCORE in "Scripting Define Symbols". We recommend transitioning as there is the possibility of removing support in the future.

refs: #661

Other Breaking Changes

  • Switch to ILogger-based logging by @mayuki in #683
  • Remove MagicOnion.Server.OpenTelemetry by @mayuki in #692
  • Cleanup MagicOnion.Shared project by @mayuki in #699
  • Remove GenerateDefineDebugAttribute and GenerateIfDirectiveAttribute by @mayuki in #701
  • Reorganize internal shared code dependency by @mayuki in #707
  • Move DynamicClientFactoryProviders to DynamicClient by @mayuki in #712
  • Remove UniTask support by @mayuki in #729

What's Changes

Features

  • Add MagicOnionClient.Create overload by @mayuki in #684
  • MagicOnion.Client targets C# 9 and enable nullable annotations by @mayuki in #698
  • Adopt to .NET 8 by @mayuki in #730

Other Changes

  • Run continuation of hub method synchronously on Unity WebGL by @mayuki in #659
  • Replace Moq with NSubstitute by @mayuki in #672
  • Fix an incorrect root when a project references a shared project. by @mayuki in #674
  • Make to accept a factory for GrpcChannelOptions by @mayuki in #678
  • Fix code generation for formatter of Enum nested in a class by @mayuki in #679
  • Make marker response bytes a constant by @mayuki in #681
  • Refactor StreamingHub by @mayuki in #682
  • Update dependencies by @mayuki in #697
  • Fix code generation for MemoryPack by @mayuki in #700
  • Revert "Merge pull request #701 from Cysharp/feature/RemoveGenerateAttribute by @mayuki in #706
  • Fix check for ignored assembly names by @mayuki in #711
  • Update action.yaml to use Cysharp/Actions/setup-dotnet by @guitarrapc in #715
  • Restore MethodCollector tests by @mayuki in #721
  • Add support for interface inheritance on StreamingHub by @mayuki in #722
  • Fix error when a source code contains alias-qualified attribute names by @mayuki in #727

Full Changelog: 5.1.8...6.0.0

Ver.5.1.8

05 Jun 07:23
Compare
Choose a tag to compare

What's Changed

Other Changes

  • Fix invalid code generation for ValueTuple by @mayuki in #651
  • Use MessagePackReader/Writer to read extra message in error responses by @mayuki in #653 (Thanks @hegi25; #650)
  • Fix unable to handle an interface with the same name by @mayuki in #654

Full Changelog: 5.1.7...5.1.8