From 8643c04a397417d4de3fc76372b6799e6a8a8b72 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Wed, 9 Oct 2019 17:06:00 +0900 Subject: [PATCH] Additional fixes for 3.0 --- BTCPayServer.Tests/CustomerHttpServer.cs | 5 ++--- BTCPayServer.Tests/TestAccount.cs | 2 +- BTCPayServer.Tests/UnitTest1.cs | 1 + BTCPayServer/Models/GetTokensResponse.cs | 4 ++++ BTCPayServer/Services/Invoices/InvoiceRepository.cs | 2 +- .../Services/PaymentRequests/PaymentRequestRepository.cs | 1 + Build/Common.csproj | 2 +- 7 files changed, 11 insertions(+), 6 deletions(-) diff --git a/BTCPayServer.Tests/CustomerHttpServer.cs b/BTCPayServer.Tests/CustomerHttpServer.cs index 34cbdefdc..af77e2e90 100644 --- a/BTCPayServer.Tests/CustomerHttpServer.cs +++ b/BTCPayServer.Tests/CustomerHttpServer.cs @@ -26,11 +26,10 @@ namespace BTCPayServer.Tests _Host = new WebHostBuilder() .Configure(app => { - app.Run(req => + app.Run(async req => { - _Requests.Writer.WriteAsync(JsonConvert.DeserializeObject(new StreamReader(req.Request.Body).ReadToEnd()), _Closed.Token); + await _Requests.Writer.WriteAsync(JsonConvert.DeserializeObject(await new StreamReader(req.Request.Body).ReadToEndAsync()), _Closed.Token); req.Response.StatusCode = 200; - return Task.CompletedTask; }); }) .UseKestrel() diff --git a/BTCPayServer.Tests/TestAccount.cs b/BTCPayServer.Tests/TestAccount.cs index 30067c13d..109079d61 100644 --- a/BTCPayServer.Tests/TestAccount.cs +++ b/BTCPayServer.Tests/TestAccount.cs @@ -182,7 +182,7 @@ namespace BTCPayServer.Tests public async Task RegisterOpenIdClient(OpenIddictApplicationDescriptor descriptor, string secret = null) { var openIddictApplicationManager = parent.PayTester.GetService>(); - var client = new BTCPayOpenIdClient {ApplicationUserId = UserId}; + var client = new BTCPayOpenIdClient { Id = Guid.NewGuid().ToString(), ApplicationUserId = UserId}; await openIddictApplicationManager.PopulateAsync(client, descriptor); await openIddictApplicationManager.CreateAsync(client, secret); return client; diff --git a/BTCPayServer.Tests/UnitTest1.cs b/BTCPayServer.Tests/UnitTest1.cs index 3a1845da8..0ed084050 100644 --- a/BTCPayServer.Tests/UnitTest1.cs +++ b/BTCPayServer.Tests/UnitTest1.cs @@ -2993,6 +2993,7 @@ noninventoryitem: { var newDevice = new U2FDevice() { + Id = Guid.NewGuid().ToString(), Name = "fake", Counter = 0, KeyHandle = UTF8Encoding.UTF8.GetBytes("fake"), diff --git a/BTCPayServer/Models/GetTokensResponse.cs b/BTCPayServer/Models/GetTokensResponse.cs index 25b61a6ac..5836806cc 100644 --- a/BTCPayServer/Models/GetTokensResponse.cs +++ b/BTCPayServer/Models/GetTokensResponse.cs @@ -47,7 +47,11 @@ namespace BTCPayServer.Models } context.HttpContext.Response.Headers.Add("Content-Type", new Microsoft.Extensions.Primitives.StringValues("application/json")); var str = JsonConvert.SerializeObject(jobj); +#if NETCOREAPP21 using (var writer = new StreamWriter(context.HttpContext.Response.Body, new UTF8Encoding(false), 1024 * 10, true)) +#else + await using (var writer = new StreamWriter(context.HttpContext.Response.Body, new UTF8Encoding(false), 1024 * 10, true)) +#endif { await writer.WriteAsync(str); } diff --git a/BTCPayServer/Services/Invoices/InvoiceRepository.cs b/BTCPayServer/Services/Invoices/InvoiceRepository.cs index a8315873f..4c2d83560 100644 --- a/BTCPayServer/Services/Invoices/InvoiceRepository.cs +++ b/BTCPayServer/Services/Invoices/InvoiceRepository.cs @@ -555,7 +555,7 @@ retry: if (queryObject.ExceptionStatus != null && queryObject.ExceptionStatus.Length > 0) { - var exceptionStatusSet = queryObject.ExceptionStatus.Select(s => NormalizeExceptionStatus(s)).ToHashSet(); + var exceptionStatusSet = queryObject.ExceptionStatus.Select(s => NormalizeExceptionStatus(s)).ToHashSet().ToArray(); query = query.Where(i => exceptionStatusSet.Contains(i.ExceptionStatus)); } diff --git a/BTCPayServer/Services/PaymentRequests/PaymentRequestRepository.cs b/BTCPayServer/Services/PaymentRequests/PaymentRequestRepository.cs index b103fb5c8..406164257 100644 --- a/BTCPayServer/Services/PaymentRequests/PaymentRequestRepository.cs +++ b/BTCPayServer/Services/PaymentRequests/PaymentRequestRepository.cs @@ -31,6 +31,7 @@ namespace BTCPayServer.Services.PaymentRequests { if (string.IsNullOrEmpty(entity.Id)) { + entity.Id = Guid.NewGuid().ToString(); await context.PaymentRequests.AddAsync(entity); } else diff --git a/Build/Common.csproj b/Build/Common.csproj index e7fcac29d..c2b7bc056 100644 --- a/Build/Common.csproj +++ b/Build/Common.csproj @@ -3,7 +3,7 @@ netcoreapp2.1 $(TargetFrameworkOverride) NU1701,CA1816,CA1308,CA1810,CA2208 - 7.3 + 8.0 $(DefineConstants);NETCOREAPP21