Skip to content

Releases: Cysharp/MagicOnion

Ver.5.1.7

22 May 02:56
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: 5.1.6...5.1.7

Ver.5.1.6

28 Apr 10:13
Compare
Choose a tag to compare

What's Changed

Other Changes

New Contributors

Full Changelog: 5.1.5...5.1.6

Ver.5.1.5

11 Apr 08:21
Compare
Choose a tag to compare

What's Changed

Full Changelog: 5.1.2...5.1.5

Ver.5.1.4

11 Apr 07:36
Compare
Choose a tag to compare

What's Changed

  • Emit type hints for Ahead-of-Time compilation by @mayuki in #630
  • Fix build error on IL2CPP by @mayuki in #632

Full Changelog: 5.1.2...5.1.4

Ver.5.1.3

11 Apr 06:42
Compare
Choose a tag to compare

What's Changed

  • Emit type hints for Ahead-of-Time compilation by @mayuki in #630

Full Changelog: 5.1.2...5.1.3

Ver.5.1.2

02 Feb 06:37
Compare
Choose a tag to compare

What's Changed

Other Changes

  • Fix conditions for enabling DynamicClient on Unity by @mayuki in #612, #614
  • Update well-known formatters for MessagePack and MemoryPack by @mayuki in #613

Full Changelog: 5.1.0...5.1.2

Ver.5.1.0

27 Jan 10:41
Compare
Choose a tag to compare

⚠ Important: Fixes handling of null values in request/response. in #610

Version 5.0.x series cannot handle null passed in the request and response.

If the request/response is value type (struct) or if the method takes more than one argument, it is not affected, but we strongly recommend upgrading.

Breaking changes

ResponseContext<T> class is now abstract and ResponseContext<T>.Create method is used instead of a constructor.

What's Changed

Bug Fixes

  • Fix method signature of MemoryPackFormatter for Unity by @mayuki in #611
  • Remove DynamicClientBuilder when targeting .NET Standard on Unity by @mayuki in #606

Other Changes

New Contributors

Full Changelog: 5.0.2...5.1.0

Ver.5.0.2

06 Jan 06:52
Compare
Choose a tag to compare

What's Changed

  • Fix unexpected type loading when ReflectionTypeLoadException is thrown by @mayuki in #598

Full Changelog: 5.0.1...5.0.2

Ver.5.0.1

04 Jan 07:28
Compare
Choose a tag to compare

What's Changed

  • ReadMe: use minimal api template by @neuecc in #592
  • Fix preprocessor conditions for Unity by @mayuki in #594
  • chore: Apply Testcontainers for .NET best practices by @HofmeisterAn in #593
  • Make StructLayout of DynamicArgumentTuples to LayoutKind.Auto by @mayuki in #595, #596
  • Rewriting to Top-level statements style. by @mayuki in #597

New Contributors

Full Changelog: 5.0.0...5.0.1

Ver.5.0.0

28 Dec 02:42
Compare
Choose a tag to compare

Highlights

Update supporting platforms

  • Bump supported Unity version to 2020.3 (LTS) or later (C# 8.0)
  • Add support for .NET 7 and drop support for .NET Core 3.1, .NET 5 on servers

Adopt to .NET 7 and drop support for .NET Core 3.1, .NET 5 on servers #573

MagicOnion now supports .NET 7 and we drop support for .NET Core 3.1 and .NET 5 on servers.

  • MagicOnion.Server supports only .NET 7 and .NET 6.
  • MagicOnion.Client continues to support .NET Standard 2.x.
    • If the client application which built/run on .NET 5 or .NET Core 3.1 runtime, it still can depend on the package for .NET Standard.

Non-Generic UnaryResult #579

Non-generic UnaryResult is the return type of a service method that does not return a value. It replaces UnaryResult<Nil>, which is similar to Task and ValueTask.

// Shared interface:
public interface IMyService : IService<IMyService>
{
    UnaryResult MethodAsync(int arg0);
}

// Server-side:
public class MyService : ServiceBase<IMyService>, IMyService
{
    public async UnaryResult MethodAsync(int arg0)
    {
        // Do something ...
        // The method does not return any value. (like void, ValueTask, Task)
    }
}

// Client-side:
await client.MethodAsync(1234);

Breaking changes

UnaryResult has changed from static class to struct.

Allow ValueTask as a return type of the hub method. #583

MagicOnion 5.0 allows ValueTask and ValueTask<T> as a return type of the hub method. Previously, only Task wereTask<T> was allowed.

public interface IMyHub : IStreamingHub<IMyHub, IMyHubReceiver>
{
    ValueTask FooAsync();
    ValueTask<int> BarAsync();
}

Rework Server-side Filter APIs #552

Introduce IMagicOnionServiceFilter, IStreamingHubFilter

The filter implementation changes from overriding attributes to implementing interfaces.

  • IMagicOnionServiceFilter
  • IStreamingHubFilter
  • IMagicOnionFilterFactory<T>
  • IMagicOnionOrderedFilter

This makes for a more flexible implementation, such as implementing both Unary filter and StreamingHub filter.

public class MyDualFilterAttribute : Attribute, IMagicOnionServiceFilter, IStreamingHubFilter, IMagicOnionOrderedFilter
{
    public int Order { get; set; } = int.MaxValue;

    ValueTask IMagicOnionServiceFilter.Invoke(ServiceContext context, Func<ServiceContext, ValueTask> next) { ... }
    ValueTask IStreamingHubFilter.Invoke(StreamingHubContext context, Func<StreamingHubContext, ValueTask> next) { ... }
}

public class MyFilterAttribute : Attribute, IMagicOnionFilterFactory<IMagicOnionServiceFilter>, IMagicOnionOrderedFilter
{
    public int Order { get; set; } = int.MaxValue;

    public IMagicOnionServiceFilter CreateInstance(IServiceProvider serviceProvider)
        => new FilterImpl();

    class FilterImpl : IMagicOnionServiceFilter
    {
        public ValueTask Invoke(ServiceContext context, Func<ServiceContext, ValueTask> next) { ... }
    }
}

This changes MagicOnionFilterAttribute, StreamingHubFilterAttribute as follows:

// 4.x or earlier
public abstract class MagicOnionFilterAttribute : Attribute { ... }
public abstract class StreamingHubFilterAttribute : Attribute { ... }
// 5.0
public abstract class MagicOnionFilterAttribute : Attribute, IMagicOnionServiceFilter, IMagicOnionOrderedFilter { ... }
public abstract class StreamingHubFilterAttribute : Attribute, IStreamingHubFilter, IMagicOnionOrderedFilter { ... }

These have methods for implementation and can continue to be overridden.

Breaking changes

  • IMagicOnionFilterFactory<T> has been moved under MagicOnion.Server.Filters namespace.

Minor changes

  • Use ServiceProvider and ActivatorUtilities to create an instance of filter or filter factory
  • Specifying the implicit order of filters: [Manually ordered filters] -> [Global Filters] -> [Class Filters] -> [Method Filters]
    • The filters have int.MaxValue as the implicit order by default.

Read and write directly to the buffer using IBufferWriter when calling Unary #496

Read and write directly to the buffer using IBufferWriter when calling Unary.
Unary requests can be processed up to 5-10% more efficiently.

Breaking changes

  • Remove request/response parameter from IMagicOnionLogger
  • Remove MagicOnionLogToLoggerWithDataDump, MagicOnionLogToLoggerWithNamedDataDump
  • Change the signature of SetRawRequest / GetRawRequest from byte[] to object

Rework {Server,Client,Duplex}Streaming #558

Change {Server,Client,Duplex}Streaming message processing on the server to IBufferWriter-based.

Breaking changes

  • Remove data parameter from IMagicOnionLogger.WriteToStream, IMagicOnionLogger.ReadFromStream

Rework MagicOnionClient #530

MagicOnionClient client now uses IBufferWriter<T>.
Marshaller wrapper API for encryption will be worked on in a separate PR.

Improvements

  • More efficient memory usages
    • Use buffers directly for serialization to reduce unnecessary byte allocation.
  • DynamicClientBuilder and MagicOnionGenerator produce very similar code generation.

Breaking changes

  • Bump supported Unity version to 2020.3 (LTS) or later (C# 8.0)
  • RequestMutator and ResponseMutator are no longer supported.
    • We plan to introduce a new wrapper API for Marshaller.
  • Task<UnaryResult<T>> is no longer supported as a return type of Unary method.
    • Use UnaryResult<T> instead.
  • moc (MagicOnion.Generator) is no longer published to GitHub Releases.
    • We recommend that the generator be used with .NET CLI Tool.

Extensible message serialization #577

MagicOnion uses MessagePack for serialization by default, but it also provides extension points to customize serialization.
It allows for customization, such as encryption and the using of serializers other than MessagePack.

Breaking changes

  • Client: MagicOnionClient and StreamingHubClient now receives IMagicOnionSerializerProvider instead of MessagePackSerializerOptions.
  • Server: Use MagicOnionOptions.MessageSerializer instead of MagicOnionOptions.SerializerOptions

New APIs

public interface IMagicOnionSerializerProvider
{
    IMagicOnionSerializer Create(MethodType methodType, MethodInfo? methodInfo);
}

public interface IMagicOnionSerializer
{
    void Serialize<T>(IBufferWriter<byte> writer, in T? value);
    T? Deserialize<T>(in ReadOnlySequence<byte> bytes);
}

public static class MagicOnionSerializerProvider
{
    public static IMagicOnionSerializerProvider Default { get; set; } = MessagePackMagicOnionSerializerProvider.Default;
}

Use ModuleInitializer for automatic registration on .NET 5+ #578

Use ModuleInitializer for automatic registration on .NET 5+. When an application running on .NET 5+ uses a generated client, MagicOnionInitializer.Register() is automatically called.

Notable changes

Option --no-use-unity-attr is obsoleted, please use --disable-auto-register instead.

Support for serialization using MemoryPack #590

Adds support for serialization using MemoryPack. (Preview)
Set MemoryPackMagicOnionSerializerProvider to MagicOnionSerializerProvider on the client and server to serialize using MemoryPack.

MagicOnionSerializerProvider.Default = MemoryPackMagicOnionSerializerProvider.Instance;

// or

await StreamingHubClient.ConnectAsync<IMyHub, IMyHubReceiver>(channel, receiver, serializerProvider: MemoryPackMagicOnionSerializerProvider.Instance);
MagicOnionClient.Create<IMyService>(channel, MemoryPackMagicOnionSerializerProvider.Instance);

Using with Code Generator

If you want to use MagicOnion.Generator (moc), you need to specify --serializer MemoryPack as an option.
The generated code will use MemoryPack instead of MessagePack.

The application must also call MagicOnionMemoryPackFormatterProvider.RegisterFormatters() on startup.

What's Changed

Breaking Changes

  • Rework MagicOnionClient by @mayuki in #530
  • Rework Server-side Filter APIs by @mayuki in #552
  • Move loggers to MagicOnion.Server.Diagnostics by @mayuki in #557
  • Rework {Server,Client,Duplex}Streaming by @mayuki in #558
  • Adopt to .NET 7 and drop support for .NET Core 3.1, .NET 5 on servers by @mayuki in #573
  • Remove ChangeSerializer from ServiceContext by @mayuki in #580
  • Drop MagicOnion.MSBuild.Tasks by @mayuki in #582
  • Remove UnaryResult() and ReturnNil() helper methods by @mayuki in #589

Features

  • Read and write directly to the buffer using IBufferWriter when calling Unary by @mayuki in #496
  • Allow ValueTask as a return type of the hub method. by @mayuki in #583
  • Introduce ClientFactoryProvider by @mayuki in #588
  • Support for serialization using MemoryPack by @mayuki in #590
  • Use ModuleInitializer for automatic registration on .NET 5+ by @mayuki in #578
  • Non-Generic UnaryResult by @mayuki in #579
  • Extensible message serialization by @mayuki in #577

Other Changes

Read more