mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 06:24:24 +01:00
Cleanup netcore21 specific code
This commit is contained in:
@@ -3,8 +3,7 @@
|
||||
<Import Project="../Build/Common.csproj" />
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.14" Condition="'$(TargetFramework)' == 'netcoreapp2.1'" />
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" Condition="'$(TargetFramework)' != 'netcoreapp2.1'" />
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="NBXplorer.Client" Version="3.0.1" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
#if !NETCOREAPP21
|
||||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
@@ -235,25 +234,3 @@ namespace Microsoft.Extensions.Logging.Abstractions.Internal
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#else
|
||||
using Microsoft.Extensions.Options;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides programmatic configuration for JSON formatters using Newtonsoft.JSON.
|
||||
/// </summary>
|
||||
public class MvcNewtonsoftJsonOptions
|
||||
{
|
||||
IOptions<MvcJsonOptions> jsonOptions;
|
||||
public MvcNewtonsoftJsonOptions(IOptions<MvcJsonOptions> jsonOptions)
|
||||
{
|
||||
this.jsonOptions = jsonOptions;
|
||||
}
|
||||
public JsonSerializerSettings SerializerSettings => this.jsonOptions.Value.SerializerSettings;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="../Build/Version.csproj" Condition="Exists('../Build/Version.csproj')" />
|
||||
<Import Project="../Build/Common.csproj" />
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
|
||||
<PackageReference Include="Microsoft.AspNetCore.App" AllowExplicitVersion="true" Version="2.1.14" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.14" />
|
||||
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.1.4" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.1.2" />
|
||||
<PackageReference Include="OpenIddict.EntityFrameworkCore" Version="3.0.0-alpha1.20058.15" />
|
||||
</ItemGroup>
|
||||
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp2.1'">
|
||||
<ItemGroup>
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.0" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="3.1.0" />
|
||||
|
||||
@@ -45,11 +45,7 @@ namespace BTCPayServer.Data
|
||||
|
||||
class CustomNpgsqlMigrationsSqlGenerator : NpgsqlMigrationsSqlGenerator
|
||||
{
|
||||
#if NETCOREAPP21
|
||||
public CustomNpgsqlMigrationsSqlGenerator(MigrationsSqlGeneratorDependencies dependencies) : base(dependencies)
|
||||
#else
|
||||
public CustomNpgsqlMigrationsSqlGenerator(MigrationsSqlGeneratorDependencies dependencies, IMigrationsAnnotationProvider annotations, Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure.Internal.INpgsqlOptions opts) : base(dependencies, annotations, opts)
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -7,10 +7,9 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.14" Condition="'$(TargetFramework)' == 'netcoreapp2.1'" />
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" Condition="'$(TargetFramework)' != 'netcoreapp2.1'" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.4.0" Condition="'$(TargetFramework)' != 'netcoreapp2.1'" />
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" Condition="'$(TargetFramework)' != 'netcoreapp2.1'" />
|
||||
<FrameworkReference Include="Microsoft.AspNetCore.App" />
|
||||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="3.4.0" />
|
||||
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
||||
<PackageReference Include="DigitalRuby.ExchangeSharp" Version="0.6.3" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -9,10 +9,6 @@
|
||||
<UserSecretsId>AB0AC1DD-9D26-485B-9416-56A33F268117</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
|
||||
<DefineConstants>$(DefineConstants);NETCOREAPP21</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(CI_TESTS)' == 'true'">
|
||||
<DefineConstants>$(DefineConstants);SHORT_TIMEOUT</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -5,9 +5,6 @@ using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
#if NETCOREAPP21
|
||||
using Microsoft.AspNetCore.Http.Internal;
|
||||
#endif
|
||||
using Xunit.Sdk;
|
||||
using System.Linq;
|
||||
|
||||
|
||||
@@ -57,7 +57,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.App" Version="2.1.14" AllowExplicitVersion="true" Condition="'$(TargetFramework)' == 'netcoreapp2.1'" />
|
||||
<PackageReference Include="TwentyTwenty.Storage" Version="2.11.2" />
|
||||
<PackageReference Include="TwentyTwenty.Storage.Amazon" Version="2.11.2" />
|
||||
<PackageReference Include="TwentyTwenty.Storage.Azure" Version="2.11.2" />
|
||||
@@ -68,9 +67,6 @@
|
||||
<PackageReference Include="OpenIddict" Version="3.0.0-alpha1.20058.15" />
|
||||
<PackageReference Include="OpenIddict.Server.AspNetCore" Version="3.0.0-alpha1.20058.15"></PackageReference>
|
||||
<PackageReference Include="OpenIddict.Validation.AspNetCore" Version="3.0.0-alpha1.20058.15"></PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' != 'netcoreapp2.1'">
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.0.0" Condition="'$(Configuration)' == 'Debug'" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="3.0.0"></PackageReference>
|
||||
|
||||
@@ -19,9 +19,6 @@ using System.Globalization;
|
||||
using BTCPayServer.Security;
|
||||
using BTCPayServer.U2F;
|
||||
using BTCPayServer.Data;
|
||||
#if NETCOREAPP21
|
||||
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
|
||||
#endif
|
||||
|
||||
namespace BTCPayServer.Controllers
|
||||
{
|
||||
|
||||
@@ -32,9 +32,6 @@ using Microsoft.Extensions.Options;
|
||||
using NBitcoin;
|
||||
using NBitcoin.DataEncoders;
|
||||
using Newtonsoft.Json;
|
||||
#if NETCOREAPP21
|
||||
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
|
||||
#endif
|
||||
|
||||
namespace BTCPayServer.Controllers
|
||||
{
|
||||
|
||||
@@ -41,12 +41,10 @@ namespace BTCPayServer
|
||||
{
|
||||
public static class Extensions
|
||||
{
|
||||
#if !NETCOREAPP21
|
||||
public static IQueryable<TEntity> Where<TEntity>(this Microsoft.EntityFrameworkCore.DbSet<TEntity> obj, System.Linq.Expressions.Expression<Func<TEntity, bool>> predicate) where TEntity : class
|
||||
{
|
||||
return System.Linq.Queryable.Where(obj, predicate);
|
||||
}
|
||||
#endif
|
||||
|
||||
public static string Truncate(this string value, int maxLength)
|
||||
{
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
#if NETCOREAPP21
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal;
|
||||
#else
|
||||
using Microsoft.AspNetCore.Mvc.ViewFeatures;
|
||||
#endif
|
||||
|
||||
namespace BTCPayServer
|
||||
{
|
||||
@@ -17,12 +13,8 @@ namespace BTCPayServer
|
||||
string message,
|
||||
Controller controller)
|
||||
{
|
||||
#if NETCOREAPP21
|
||||
var key = ExpressionHelper.GetExpressionText(ex);
|
||||
#else
|
||||
var provider = (ModelExpressionProvider)controller.HttpContext.RequestServices.GetService(typeof(ModelExpressionProvider));
|
||||
var key = provider.GetExpressionText(ex);
|
||||
#endif
|
||||
controller.ModelState.AddModelError(key, message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,11 +63,7 @@ namespace BTCPayServer.Hosting
|
||||
{
|
||||
public static IServiceCollection AddBTCPayServer(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
#if NETCOREAPP21
|
||||
services.AddSingleton<MvcNewtonsoftJsonOptions>();
|
||||
#else
|
||||
services.AddSingleton<MvcNewtonsoftJsonOptions>(o => o.GetRequiredService<IOptions<MvcNewtonsoftJsonOptions>>().Value);
|
||||
#endif
|
||||
services.AddDbContext<ApplicationDbContext>((provider, o) =>
|
||||
{
|
||||
var factory = provider.GetRequiredService<ApplicationDbContextFactory>();
|
||||
|
||||
@@ -6,12 +6,8 @@ using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using BundlerMinifier.TagHelpers;
|
||||
#if NETCOREAPP21
|
||||
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
|
||||
#else
|
||||
using Newtonsoft.Json.Serialization;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
#endif
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace BTCPayServer.Hosting
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
#if NETCOREAPP21
|
||||
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
|
||||
#else
|
||||
using Microsoft.Extensions.Hosting;
|
||||
#endif
|
||||
using OpenIddict.Validation.AspNetCore;
|
||||
using OpenIddict.Abstractions;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
@@ -78,11 +74,9 @@ namespace BTCPayServer.Hosting
|
||||
// ScriptSrc = "'self' 'unsafe-inline'"
|
||||
//});
|
||||
})
|
||||
#if !NETCOREAPP21
|
||||
.AddNewtonsoftJson()
|
||||
#if DEBUG
|
||||
.AddRazorRuntimeCompilation()
|
||||
#endif
|
||||
#endif
|
||||
.AddControllersAsServices();
|
||||
services.TryAddScoped<ContentSecurityPolicies>();
|
||||
@@ -239,35 +233,18 @@ namespace BTCPayServer.Hosting
|
||||
forwardingOptions.ForwardedHeaders = ForwardedHeaders.All;
|
||||
app.UseForwardedHeaders(forwardingOptions);
|
||||
app.UsePayServer();
|
||||
#if !NETCOREAPP21
|
||||
app.UseRouting();
|
||||
#endif
|
||||
app.UseCors();
|
||||
|
||||
app.UseStaticFiles();
|
||||
app.UseProviderStorage(options);
|
||||
app.UseAuthentication();
|
||||
#if !NETCOREAPP21
|
||||
app.UseAuthorization();
|
||||
#endif
|
||||
app.UseSession();
|
||||
#if NETCOREAPP21
|
||||
app.UseSignalR(route =>
|
||||
{
|
||||
AppHub.Register(route);
|
||||
PaymentRequestHub.Register(route);
|
||||
});
|
||||
#endif
|
||||
|
||||
app.UseWebSockets();
|
||||
app.UseStatusCodePages();
|
||||
#if NETCOREAPP21
|
||||
app.UseMvc(routes =>
|
||||
{
|
||||
routes.MapRoute(
|
||||
name: "default",
|
||||
template: "{controller=Home}/{action=Index}/{id?}");
|
||||
});
|
||||
#else
|
||||
|
||||
app.UseEndpoints(endpoints =>
|
||||
{
|
||||
AppHub.Register(endpoints);
|
||||
@@ -275,7 +252,6 @@ namespace BTCPayServer.Hosting
|
||||
endpoints.MapControllers();
|
||||
endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
|
||||
});
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,11 +47,7 @@ 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);
|
||||
}
|
||||
|
||||
@@ -14,10 +14,8 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using BTCPayServer.Data;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
#if !NETCOREAPP21
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
#endif
|
||||
|
||||
namespace BTCPayServer.PaymentRequest
|
||||
{
|
||||
@@ -90,11 +88,7 @@ namespace BTCPayServer.PaymentRequest
|
||||
return request.GetRelativePathOrAbsolute("/payment-requests/hub");
|
||||
}
|
||||
|
||||
#if NETCOREAPP21
|
||||
public static void Register(HubRouteBuilder route)
|
||||
#else
|
||||
public static void Register(IEndpointRouteBuilder route)
|
||||
#endif
|
||||
{
|
||||
route.MapHub<PaymentRequestHub>("/payment-requests/hub");
|
||||
}
|
||||
|
||||
@@ -20,10 +20,6 @@ using BTCPayServer.Payments;
|
||||
using BTCPayServer.HostedServices;
|
||||
using NBitcoin.Altcoins.Elements;
|
||||
|
||||
#if NETCOREAPP21
|
||||
using IHostApplicationLifetime = Microsoft.AspNetCore.Hosting.IApplicationLifetime;
|
||||
#endif
|
||||
|
||||
namespace BTCPayServer.Payments.Bitcoin
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -5,10 +5,8 @@ using BTCPayServer.Models.AppViewModels;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
#if !NETCOREAPP21
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
#endif
|
||||
|
||||
namespace BTCPayServer.Services.Apps
|
||||
{
|
||||
@@ -70,11 +68,8 @@ namespace BTCPayServer.Services.Apps
|
||||
{
|
||||
return request.GetRelativePathOrAbsolute("/apps/hub");
|
||||
}
|
||||
#if NETCOREAPP21
|
||||
public static void Register(HubRouteBuilder route)
|
||||
#else
|
||||
|
||||
public static void Register(IEndpointRouteBuilder route)
|
||||
#endif
|
||||
{
|
||||
route.MapHub<AppHub>("/apps/hub");
|
||||
}
|
||||
|
||||
@@ -8,11 +8,7 @@ using NBXplorer;
|
||||
using NBitcoin;
|
||||
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
|
||||
{
|
||||
|
||||
@@ -89,18 +89,12 @@ retry:
|
||||
using (var db = _ContextFactory.CreateContext())
|
||||
{
|
||||
return (await db.AddressInvoices
|
||||
#if !NETCOREAPP21
|
||||
.Include(a => a.InvoiceData.Payments)
|
||||
.Include(a => a.InvoiceData.RefundAddresses)
|
||||
#endif
|
||||
#pragma warning disable CS0618
|
||||
.Where(a => addresses.Contains(a.Address))
|
||||
#pragma warning restore CS0618
|
||||
.Select(a => a.InvoiceData)
|
||||
#if NETCOREAPP21
|
||||
.Include(a => a.Payments)
|
||||
.Include(a => a.RefundAddresses)
|
||||
#endif
|
||||
.ToListAsync()).Select(ToEntity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,12 +5,7 @@ using Microsoft.Extensions.Hosting;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
#if NETCOREAPP21
|
||||
using IWebHostEnvironment = Microsoft.AspNetCore.Hosting.IHostingEnvironment;
|
||||
using Microsoft.AspNetCore.Hosting.Internal;
|
||||
#else
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
#endif
|
||||
|
||||
namespace BTCPayServer.Services
|
||||
{
|
||||
@@ -34,11 +29,7 @@ namespace BTCPayServer.Services
|
||||
|
||||
public LanguageService(IWebHostEnvironment environment)
|
||||
{
|
||||
#if NETCOREAPP21
|
||||
var path = (environment as HostingEnvironment)?.WebRootPath;
|
||||
#else
|
||||
var path = environment.WebRootPath;
|
||||
#endif
|
||||
path = Path.Combine(path, "locales");
|
||||
var files = Directory.GetFiles(path, "*.json");
|
||||
var result = new List<Language>();
|
||||
|
||||
@@ -5,7 +5,4 @@
|
||||
<NoWarn>NU1701,CA1816,CA1308,CA1810,CA2208</NoWarn>
|
||||
<LangVersion>8.0</LangVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'netcoreapp2.1'">
|
||||
<DefineConstants>$(DefineConstants);NETCOREAPP21</DefineConstants>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
@@ -14,6 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Misc", "Misc", "{29290EC7-0
|
||||
Build\Common.csproj = Build\Common.csproj
|
||||
.circleci\config.yml = .circleci\config.yml
|
||||
docker-entrypoint.sh = docker-entrypoint.sh
|
||||
linuxarm64v8.Dockerfile = linuxarm64v8.Dockerfile
|
||||
Build\Version.csproj = Build\Version.csproj
|
||||
EndProjectSection
|
||||
EndProject
|
||||
|
||||
Reference in New Issue
Block a user