From e75edac3c185bda9d6bac30adb5decb1302d0079 Mon Sep 17 00:00:00 2001 From: "nicolas.dorier" Date: Thu, 3 Oct 2019 18:00:07 +0900 Subject: [PATCH] Make .netcoreapp 3.0 build happy --- BTCPayServer/BTCPayServer.csproj | 1 + BTCPayServer/Controllers/WalletsController.cs | 6 ++--- BTCPayServer/CurrencyValue.cs | 2 +- .../Extensions/ModelStateExtensions.cs | 24 +++++++++---------- .../Filters/XXSSProtectionAttribute.cs | 2 -- BTCPayServer/Hosting/Startup.cs | 2 ++ .../DerivationSchemeModelBinder.cs | 1 - .../Services/BTCPayServerEnvironment.cs | 2 ++ .../Crowdfund/ContributeForm.cshtml | 8 +++---- BTCPayServer/Views/Server/Logs.cshtml | 4 ++-- 10 files changed, 26 insertions(+), 26 deletions(-) diff --git a/BTCPayServer/BTCPayServer.csproj b/BTCPayServer/BTCPayServer.csproj index 2e9d08d4e..4494ec3f8 100644 --- a/BTCPayServer/BTCPayServer.csproj +++ b/BTCPayServer/BTCPayServer.csproj @@ -72,6 +72,7 @@ + diff --git a/BTCPayServer/Controllers/WalletsController.cs b/BTCPayServer/Controllers/WalletsController.cs index 72d23ce55..b808df17b 100644 --- a/BTCPayServer/Controllers/WalletsController.cs +++ b/BTCPayServer/Controllers/WalletsController.cs @@ -393,7 +393,7 @@ namespace BTCPayServer.Controllers !transactionOutput.SubtractFeesFromOutput) vm.AddModelError(model => model.Outputs[i].SubtractFeesFromOutput, "You are sending your entire balance to the same destination, you should subtract the fees", - ModelState); + this); } } @@ -402,7 +402,7 @@ namespace BTCPayServer.Controllers foreach (var subtractFeesOutput in subtractFeesOutputsCount) { vm.AddModelError(model => model.Outputs[subtractFeesOutput].SubtractFeesFromOutput, - "You can only subtract fees from one output", ModelState); + "You can only subtract fees from one output", this); } }else if (vm.CurrentBalance == transactionAmountSum && !substractFees) { @@ -415,7 +415,7 @@ namespace BTCPayServer.Controllers for (var i = 0; i < vm.Outputs.Count; i++) { vm.AddModelError(model => model.Outputs[i].Amount, - "You are sending more than what you own", ModelState); + "You are sending more than what you own", this); } } diff --git a/BTCPayServer/CurrencyValue.cs b/BTCPayServer/CurrencyValue.cs index ef3f2d812..e8b221e09 100644 --- a/BTCPayServer/CurrencyValue.cs +++ b/BTCPayServer/CurrencyValue.cs @@ -20,7 +20,7 @@ namespace BTCPayServer !decimal.TryParse(match.Groups[1].Value, out var v)) return false; - var currency = match.Groups.Last().Value.ToUpperInvariant(); + var currency = match.Groups[match.Groups.Count - 1].Value.ToUpperInvariant(); var currencyData = _CurrencyTable.GetCurrencyData(currency, false); if (currencyData == null) return false; diff --git a/BTCPayServer/Extensions/ModelStateExtensions.cs b/BTCPayServer/Extensions/ModelStateExtensions.cs index 3576f4d66..fb496875f 100644 --- a/BTCPayServer/Extensions/ModelStateExtensions.cs +++ b/BTCPayServer/Extensions/ModelStateExtensions.cs @@ -1,29 +1,29 @@ using System; using System.Linq.Expressions; -using Microsoft.AspNetCore.Mvc.ModelBinding; +using Microsoft.AspNetCore.Mvc; +#if NETCOREAPP21 using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal; +#else +using Microsoft.AspNetCore.Mvc.ViewFeatures; +#endif namespace BTCPayServer { public static class ModelStateExtensions { - public static void AddModelError( - this ModelStateDictionary modelState, - Expression> ex, - string message - ) - { - var key = ExpressionHelper.GetExpressionText(ex); - modelState.AddModelError(key, message); - } public static void AddModelError(this TModel source, Expression> ex, string message, - ModelStateDictionary modelState) + Controller controller) { +#if NETCOREAPP21 var key = ExpressionHelper.GetExpressionText(ex); - modelState.AddModelError(key, message); +#else + var provider = (ModelExpressionProvider)controller.HttpContext.RequestServices.GetService(typeof(ModelExpressionProvider)); + var key = provider.GetExpressionText(ex); +#endif + controller.ModelState.AddModelError(key, message); } } } diff --git a/BTCPayServer/Filters/XXSSProtectionAttribute.cs b/BTCPayServer/Filters/XXSSProtectionAttribute.cs index a929ba664..ee118dabb 100644 --- a/BTCPayServer/Filters/XXSSProtectionAttribute.cs +++ b/BTCPayServer/Filters/XXSSProtectionAttribute.cs @@ -3,8 +3,6 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc.Filters; -using Microsoft.AspNetCore.Mvc.ViewFeatures; -using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal; namespace BTCPayServer.Filters { diff --git a/BTCPayServer/Hosting/Startup.cs b/BTCPayServer/Hosting/Startup.cs index 9ea266990..716b375ee 100644 --- a/BTCPayServer/Hosting/Startup.cs +++ b/BTCPayServer/Hosting/Startup.cs @@ -1,6 +1,8 @@ using Microsoft.AspNetCore.Hosting; #if NETCOREAPP21 using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment; +#else +using Microsoft.Extensions.Hosting; #endif using Microsoft.AspNetCore.Builder; using System; diff --git a/BTCPayServer/ModelBinders/DerivationSchemeModelBinder.cs b/BTCPayServer/ModelBinders/DerivationSchemeModelBinder.cs index e7fc7f32f..f4f185272 100644 --- a/BTCPayServer/ModelBinders/DerivationSchemeModelBinder.cs +++ b/BTCPayServer/ModelBinders/DerivationSchemeModelBinder.cs @@ -3,7 +3,6 @@ using NBitcoin; using System.Reflection; using System; using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc.Internal; using NBXplorer.DerivationStrategy; namespace BTCPayServer.ModelBinders diff --git a/BTCPayServer/Services/BTCPayServerEnvironment.cs b/BTCPayServer/Services/BTCPayServerEnvironment.cs index 4cc8e50e9..6e3729eea 100644 --- a/BTCPayServer/Services/BTCPayServerEnvironment.cs +++ b/BTCPayServer/Services/BTCPayServerEnvironment.cs @@ -10,6 +10,8 @@ using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Hosting; #if NETCOREAPP21 using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment; +#else +using Microsoft.Extensions.Hosting; #endif namespace BTCPayServer.Services diff --git a/BTCPayServer/Views/AppsPublic/Crowdfund/ContributeForm.cshtml b/BTCPayServer/Views/AppsPublic/Crowdfund/ContributeForm.cshtml index e9c0ec51a..74f45b18a 100644 --- a/BTCPayServer/Views/AppsPublic/Crowdfund/ContributeForm.cshtml +++ b/BTCPayServer/Views/AppsPublic/Crowdfund/ContributeForm.cshtml @@ -1,5 +1,3 @@ -@using Microsoft.EntityFrameworkCore.Internal -@using Microsoft.EntityFrameworkCore.Storage @model BTCPayServer.Models.AppViewModels.ContributeToCrowdfund
@@ -8,7 +6,7 @@
@if (Model.ViewCrowdfundViewModel.DisplayPerksRanking && Model.ViewCrowdfundViewModel.PerkCount.ContainsKey(item.Id)) { - #@(Model.ViewCrowdfundViewModel.Perks.IndexOf(item)+1) + #@(Array.IndexOf(Model.ViewCrowdfundViewModel.Perks, item) + 1) } @if (!string.IsNullOrEmpty(item.Image)) { @@ -31,12 +29,12 @@ @item.Price.Value if (item.Custom) { - Safe.Raw("or more"); + @Safe.Raw("or more"); } } else if (item.Custom) { - Safe.Raw("Any amount"); + @Safe.Raw("Any amount"); } diff --git a/BTCPayServer/Views/Server/Logs.cshtml b/BTCPayServer/Views/Server/Logs.cshtml index 806744a86..be1439715 100644 --- a/BTCPayServer/Views/Server/Logs.cshtml +++ b/BTCPayServer/Views/Server/Logs.cshtml @@ -16,12 +16,12 @@
  • @if (Model.LogFileOffset > 0) { - << + << } Showing @Model.LogFileOffset - (@(Model.LogFileOffset+Model.LogFiles.Count)) of @Model.LogFileCount @if ((Model.LogFileOffset+ Model.LogFiles.Count) < Model.LogFileCount) { - >> + >> }