aspnetcore/breaking-changes/5/signalr-messagepack-hub-protocol-options-changed.md
The ASP.NET Core SignalR MessagePack Hub Protocol options type has changed from IList<MessagePack.IFormatterResolver> to the MessagePack library's MessagePackSerializerOptions type.
For discussion on this change, see dotnet/aspnetcore#20506.
5.0 Preview 4
You can add to the options as shown in the following example:
services.AddSignalR()
.AddMessagePackProtocol(options =>
{
options.FormatterResolvers.Add(MessagePack.Resolvers.StandardResolver.Instance);
});
And replace the options as follows:
services.AddSignalR()
.AddMessagePackProtocol(options =>
{
options.FormatterResolvers = new List<MessagePack.IFormatterResolver>()
{
MessagePack.Resolvers.StandardResolver.Instance
};
});
You can add to the options as shown in the following example:
services.AddSignalR()
.AddMessagePackProtocol(options =>
{
options.SerializerOptions =
options.SerializeOptions.WithResolver(MessagePack.Resolvers.StandardResolver.Instance);
});
And replace the options as follows:
services.AddSignalR()
.AddMessagePackProtocol(options =>
{
options.SerializerOptions = MessagePackSerializerOptions
.Standard
.WithResolver(MessagePack.Resolvers.StandardResolver.Instance)
.WithSecurity(MessagePackSecurity.UntrustedData);
});
This change is part of moving to MessagePack v2.x, which was announced in aspnet/Announcements#404. The v2.x library has added an options API that's easier to use and provides more features than the list of MessagePack.IFormatterResolver that was exposed before.
This breaking change affects anyone who is configuring values on xref:Microsoft.AspNetCore.SignalR.MessagePackHubProtocolOptions. If you're using the ASP.NET Core SignalR MessagePack Hub Protocol and modifying the options, update your usage to use the new options API as shown above.
xref:Microsoft.AspNetCore.SignalR.MessagePackHubProtocolOptions?displayProperty=nameWithType
<!-- ### Category ASP.NET Core ### Affected APIs `T:Microsoft.AspNetCore.SignalR.MessagePackHubProtocolOptions` -->