From 40f62c04846556a134c867a07de9bcd954253e43 Mon Sep 17 00:00:00 2001 From: Vincent Le Boutouiller Date: Tue, 28 Jul 2020 11:02:38 +0200 Subject: [PATCH 1/2] Avoid writer to be disposed --- src/Rdd.Web/Serialization/RddJsonResult.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Rdd.Web/Serialization/RddJsonResult.cs b/src/Rdd.Web/Serialization/RddJsonResult.cs index e3f8891d..aa35eb9f 100644 --- a/src/Rdd.Web/Serialization/RddJsonResult.cs +++ b/src/Rdd.Web/Serialization/RddJsonResult.cs @@ -50,7 +50,7 @@ public RddJsonResult(ISelection value, IExpressionTree fields) Fields = fields; } - public override Task ExecuteResultAsync(ActionContext context) + public override async Task ExecuteResultAsync(ActionContext context) { if (context == null) { @@ -70,7 +70,7 @@ public override Task ExecuteResultAsync(ActionContext context) var services = context.HttpContext.RequestServices; using (var writer = services.GetRequiredService().CreateWriter(response.Body, resolvedContentTypeEncoding)) { - return WriteResult(services, writer, DateTime.Now); + await WriteResult(services, writer, DateTime.Now); } } From 6cefbcc548b685cd054e9de0fdb3af0ac61629c1 Mon Sep 17 00:00:00 2001 From: Vincent Le Boutouiller Date: Tue, 28 Jul 2020 11:45:01 +0200 Subject: [PATCH 2/2] Add Async suffix --- src/Rdd.Web/Serialization/RddJsonResult.cs | 4 ++-- test/Rdd.Web.Tests/Serialization/FieldsTests.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Rdd.Web/Serialization/RddJsonResult.cs b/src/Rdd.Web/Serialization/RddJsonResult.cs index aa35eb9f..9da72ca1 100644 --- a/src/Rdd.Web/Serialization/RddJsonResult.cs +++ b/src/Rdd.Web/Serialization/RddJsonResult.cs @@ -70,7 +70,7 @@ public override async Task ExecuteResultAsync(ActionContext context) var services = context.HttpContext.RequestServices; using (var writer = services.GetRequiredService().CreateWriter(response.Body, resolvedContentTypeEncoding)) { - await WriteResult(services, writer, DateTime.Now); + await WriteResultAsync(services, writer, DateTime.Now); } } @@ -90,7 +90,7 @@ private string GetPrincipalName(IServiceProvider services) return name.Value; } - internal async Task WriteResult(IServiceProvider services, TextWriter writer, DateTime generatedAt) + internal async Task WriteResultAsync(IServiceProvider services, TextWriter writer, DateTime generatedAt) { Value = new Metadata(Value, GetPrincipalName(services), generatedAt); diff --git a/test/Rdd.Web.Tests/Serialization/FieldsTests.cs b/test/Rdd.Web.Tests/Serialization/FieldsTests.cs index 4b5e5ae3..dc343a83 100644 --- a/test/Rdd.Web.Tests/Serialization/FieldsTests.cs +++ b/test/Rdd.Web.Tests/Serialization/FieldsTests.cs @@ -83,7 +83,7 @@ protected async Task SerializeCorrectedFieldsAsync(RddJsonResult r { using (var writer = new StringWriter()) { - await result.WriteResult(GetServices(), writer, GeneratedAt); + await result.WriteResultAsync(GetServices(), writer, GeneratedAt); return writer.ToString(); }