Lazy-init formatter resolvers in MessagePackHubProtocolOptions (#10929)
This commit is contained in:
parent
fdba8a91f9
commit
b08577342d
|
|
@ -6,7 +6,7 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
public partial class MessagePackHubProtocolOptions
|
||||
{
|
||||
public MessagePackHubProtocolOptions() { }
|
||||
public System.Collections.Generic.IList<MessagePack.IFormatterResolver> FormatterResolvers { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute]set { } }
|
||||
public System.Collections.Generic.IList<MessagePack.IFormatterResolver> FormatterResolvers { get { throw null; } set { } }
|
||||
}
|
||||
}
|
||||
namespace Microsoft.AspNetCore.SignalR.Protocol
|
||||
|
|
|
|||
|
|
@ -9,6 +9,25 @@ namespace Microsoft.AspNetCore.SignalR
|
|||
{
|
||||
public class MessagePackHubProtocolOptions
|
||||
{
|
||||
public IList<IFormatterResolver> FormatterResolvers { get; set; } = MessagePackHubProtocol.CreateDefaultFormatterResolvers();
|
||||
private IList<IFormatterResolver> _formatterResolvers;
|
||||
|
||||
public IList<IFormatterResolver> FormatterResolvers
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_formatterResolvers == null)
|
||||
{
|
||||
// The default set of resolvers trigger a static constructor that throws on AOT environments.
|
||||
// This gives users the chance to use an AOT friendly formatter.
|
||||
_formatterResolvers = MessagePackHubProtocol.CreateDefaultFormatterResolvers();
|
||||
}
|
||||
|
||||
return _formatterResolvers;
|
||||
}
|
||||
set
|
||||
{
|
||||
_formatterResolvers = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue