Fix up ASP.NET formatter to run on .NET Core 3.1
This commit is contained in:
Родитель
e630a16dd0
Коммит
27bee7116a
|
@ -34,6 +34,12 @@ namespace MessagePack.AspNetCoreMvcFormatter
|
|||
return Task.CompletedTask;
|
||||
#else
|
||||
var writer = context.HttpContext.Response.BodyWriter;
|
||||
if (writer == null)
|
||||
{
|
||||
context.HttpContext.Response.Body.WriteByte(MessagePackCode.Nil);
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
var span = writer.GetSpan(1);
|
||||
span[0] = MessagePackCode.Nil;
|
||||
writer.Advance(1);
|
||||
|
@ -46,6 +52,11 @@ namespace MessagePack.AspNetCoreMvcFormatter
|
|||
return MessagePackSerializer.SerializeAsync(context.Object.GetType(), context.HttpContext.Response.Body, context.Object, this.options, context.HttpContext.RequestAborted);
|
||||
#else
|
||||
var writer = context.HttpContext.Response.BodyWriter;
|
||||
if (writer == null)
|
||||
{
|
||||
return MessagePackSerializer.SerializeAsync(context.Object.GetType(), context.HttpContext.Response.Body, context.Object, this.options, context.HttpContext.RequestAborted);
|
||||
}
|
||||
|
||||
MessagePackSerializer.Serialize(context.Object.GetType(), writer, context.Object, this.options, context.HttpContext.RequestAborted);
|
||||
return writer.FlushAsync().AsTask();
|
||||
#endif
|
||||
|
@ -57,6 +68,11 @@ namespace MessagePack.AspNetCoreMvcFormatter
|
|||
return MessagePackSerializer.SerializeAsync(context.ObjectType, context.HttpContext.Response.Body, context.Object, this.options, context.HttpContext.RequestAborted);
|
||||
#else
|
||||
var writer = context.HttpContext.Response.BodyWriter;
|
||||
if (writer == null)
|
||||
{
|
||||
return MessagePackSerializer.SerializeAsync(context.ObjectType, context.HttpContext.Response.Body, context.Object, this.options, context.HttpContext.RequestAborted);
|
||||
}
|
||||
|
||||
MessagePackSerializer.Serialize(context.ObjectType, writer, context.Object, this.options, context.HttpContext.RequestAborted);
|
||||
return writer.FlushAsync().AsTask();
|
||||
#endif
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.0" />
|
||||
<PackageReference Include="Moq" Version="4.10.1" />
|
||||
</ItemGroup>
|
||||
|
|
Загрузка…
Ссылка в новой задаче