瀏覽代碼

支持 .NET 6.0

Roc 3 年之前
父節點
當前提交
c6980d018f

+ 1 - 1
Directory.Build.props

@@ -31,7 +31,7 @@
   </ItemGroup>
 
   <ItemGroup>
-    <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
+    <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
   </ItemGroup>
 
 </Project>

+ 5 - 4
README.md

@@ -42,14 +42,15 @@ Package  | NuGet | Downloads | TargetFrameworks
 
 ## 开发环境
 
-* Windows 10
-* [Visual Studio 2019 16.10](https://visualstudio.microsoft.com)
-* [.NET 5.0](https://dotnet.microsoft.com/download/dotnet/5.0)
+* Windows 11
+* [Visual Studio 2022 17.0.0](https://visualstudio.microsoft.com)
+* [.NET 6.0](https://dotnet.microsoft.com/download/dotnet/6.0)
 
 ## 运行环境
 
 - [.NET Core 3.1](https://dotnet.microsoft.com/download/dotnet/3.1)
-- [.NET 5](https://dotnet.microsoft.com/download/dotnet/5.0)
+- [.NET 5.0](https://dotnet.microsoft.com/download/dotnet/5.0)
+- [.NET 6.0](https://dotnet.microsoft.com/download/dotnet/6.0)
 
 ## 使用方式
 

+ 1 - 1
global.json

@@ -1,6 +1,6 @@
 {
   "sdk": {
-    "version": "5.0.402",
+    "version": "6.0.100",
     "rollForward": "latestFeature"
   }
 }

+ 2 - 2
samples/WebApplicationSample/WebApplicationSample.csproj

@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk.Web">
 
   <PropertyGroup>
-    <TargetFramework>net5.0</TargetFramework>
+    <TargetFramework>net6.0</TargetFramework>
     <UserSecretsId>a59ca38e-9b52-44fe-b3d2-8cb5a1641623</UserSecretsId>
     <SignAssembly>false</SignAssembly>
     <GenerateDocumentationFile>false</GenerateDocumentationFile>
@@ -11,7 +11,7 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.13" />
+    <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.14.0" />
     <PackageReference Include="QRCoder" Version="1.4.1" />
   </ItemGroup>
 

+ 3 - 3
src/Essensoft.Paylink.Alipay/AlipayNotifyClient.cs

@@ -19,7 +19,7 @@ namespace Essensoft.Paylink.Alipay
 
         #region IAlipayNotifyClient Members
 
-#if NETCOREAPP3_1 || NET5_0
+#if NETCOREAPP3_1_OR_GREATER
         public async Task<T> ExecuteAsync<T>(Microsoft.AspNetCore.Http.HttpRequest request, AlipayOptions options) where T : AlipayNotify
         {
             if (options == null)
@@ -46,7 +46,7 @@ namespace Essensoft.Paylink.Alipay
 
         #region IAlipayNotifyClient Members
 
-#if NETCOREAPP3_1 || NET5_0
+#if NETCOREAPP3_1_OR_GREATER
         public Task<T> CertificateExecuteAsync<T>(Microsoft.AspNetCore.Http.HttpRequest request, AlipayOptions options) where T : AlipayNotify
         {
             return ExecuteAsync<T>(request, options);
@@ -57,7 +57,7 @@ namespace Essensoft.Paylink.Alipay
 
         #region IAlipayNotifyClient Members
 
-#if NETCOREAPP3_1 || NET5_0
+#if NETCOREAPP3_1_OR_GREATER
         public async Task<IDictionary<string, string>> GetParametersAsync(Microsoft.AspNetCore.Http.HttpRequest request)
         {
             var parameters = new Dictionary<string, string>();

+ 1 - 1
src/Essensoft.Paylink.Alipay/AlipayNotifyResult.cs

@@ -1,4 +1,4 @@
-#if NETCOREAPP3_1 || NET5_0
+#if NETCOREAPP3_1_OR_GREATER
 
 using Microsoft.AspNetCore.Mvc;
 

+ 2 - 2
src/Essensoft.Paylink.Alipay/Essensoft.Paylink.Alipay.csproj

@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
   <PropertyGroup>
-    <TargetFrameworks>netstandard2.1;netcoreapp3.1;net5.0</TargetFrameworks>
+    <TargetFrameworks>netstandard2.1;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
     <PackageId>Essensoft.Paylink.Alipay</PackageId>
     <PackageTags>Essensoft;Paylink;Alipay;支付宝</PackageTags>
   </PropertyGroup>
@@ -11,7 +11,7 @@
     <PackageReference Include="Microsoft.Extensions.Http" Version="$(MicrosoftExtensionsHttpPackageVersion)" />
   </ItemGroup>
 
-  <ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1' or '$(TargetFramework)' == 'net5.0'">
+  <ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1' or '$(TargetFramework)' == 'net5.0' or '$(TargetFramework)' == 'net6.0'">
     <FrameworkReference Include="Microsoft.AspNetCore.App" />
   </ItemGroup>
 

+ 1 - 1
src/Essensoft.Paylink.Alipay/IAlipayNotifyClient.cs

@@ -8,7 +8,7 @@ namespace Essensoft.Paylink.Alipay
     /// </summary>
     public interface IAlipayNotifyClient
     {
-#if NETCOREAPP3_1 || NET5_0
+#if NETCOREAPP3_1_OR_GREATER
         /// <summary>
         /// 执行 Alipay 通知请求解析。
         /// </summary>

+ 1 - 1
src/Essensoft.Paylink.Security/Essensoft.Paylink.Security.csproj

@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
   <PropertyGroup>
-    <TargetFrameworks>netstandard2.1;net5.0</TargetFrameworks>
+    <TargetFrameworks>netstandard2.1;net5.0;net6.0</TargetFrameworks>
     <PackageId>Essensoft.Paylink.Security</PackageId>
     <PackageTags>Essensoft;Paylink;Security</PackageTags>
   </PropertyGroup>

+ 1 - 1
src/Essensoft.Paylink.Security/HMAC_SHA256.cs

@@ -20,7 +20,7 @@ namespace Essensoft.Paylink.Security
             using (var hmacSha256 = new System.Security.Cryptography.HMACSHA256(Encoding.UTF8.GetBytes(key)))
             {
                 var hash = hmacSha256.ComputeHash(Encoding.UTF8.GetBytes(data));
-#if NET5_0
+#if NET5_0_OR_GREATER
                 return Convert.ToHexString(hash);
 #else
                 return BitConverter.ToString(hash).Replace("-", "");

+ 1 - 1
src/Essensoft.Paylink.Security/MD5.cs

@@ -15,7 +15,7 @@ namespace Essensoft.Paylink.Security
             using (var md5 = System.Security.Cryptography.MD5.Create())
             {
                 var hash = md5.ComputeHash(Encoding.UTF8.GetBytes(data));
-#if NET5_0
+#if NET5_0_OR_GREATER
                 return Convert.ToHexString(hash);
 #else
                 return BitConverter.ToString(hash).Replace("-", "");

+ 2 - 2
src/Essensoft.Paylink.WeChatPay/Essensoft.Paylink.WeChatPay.csproj

@@ -1,7 +1,7 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
   <PropertyGroup>
-    <TargetFrameworks>netstandard2.1;netcoreapp3.1;net5.0</TargetFrameworks>
+    <TargetFrameworks>netstandard2.1;netcoreapp3.1;net5.0;net6.0</TargetFrameworks>
     <PackageId>Essensoft.Paylink.WeChatPay</PackageId>
     <PackageTags>Essensoft;Paylink;WeChatPay;微信支付</PackageTags>
   </PropertyGroup>
@@ -11,7 +11,7 @@
     <PackageReference Include="Microsoft.Extensions.Http" Version="$(MicrosoftExtensionsHttpPackageVersion)" />
   </ItemGroup>
 
-  <ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1' or '$(TargetFramework)' == 'net5.0'">
+  <ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1' or '$(TargetFramework)' == 'net5.0' or '$(TargetFramework)' == 'net6.0'">
     <FrameworkReference Include="Microsoft.AspNetCore.App" />
   </ItemGroup>
 

+ 1 - 1
src/Essensoft.Paylink.WeChatPay/V2/IWeChatPayNotifyClient.cs

@@ -7,7 +7,7 @@ namespace Essensoft.Paylink.WeChatPay.V2
     /// </summary>
     public interface IWeChatPayNotifyClient
     {
-#if NETCOREAPP3_1 || NET5_0
+#if NETCOREAPP3_1_OR_GREATER
         /// <summary>
         /// 执行 WeChatPay V2 通知请求解析
         /// </summary>

+ 6 - 0
src/Essensoft.Paylink.WeChatPay/V2/Parser/WeChatPayObjectJsonParser.cs

@@ -1,12 +1,18 @@
 using System;
 using System.Text.Encodings.Web;
 using System.Text.Json;
+using System.Text.Json.Serialization;
 
 namespace Essensoft.Paylink.WeChatPay.V2.Parser
 {
     public class WeChatPayObjectJsonParser<T> where T : WeChatPayObject
     {
+
+#if NET6_0_OR_GREATER
+        private static readonly JsonSerializerOptions jsonSerializerOptions = new() { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping };
+#else
         private static readonly JsonSerializerOptions jsonSerializerOptions = new() { IgnoreNullValues = true, Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping };
+#endif
 
         public T Parse(string body)
         {

+ 1 - 1
src/Essensoft.Paylink.WeChatPay/V2/WeChatPayNotifyClient.cs

@@ -21,7 +21,7 @@ namespace Essensoft.Paylink.WeChatPay.V2
 
         #region IWeChatPayNotifyClient Members
 
-#if NETCOREAPP3_1 || NET5_0
+#if NETCOREAPP3_1_OR_GREATER
         public async Task<T> ExecuteAsync<T>(Microsoft.AspNetCore.Http.HttpRequest request, WeChatPayOptions options) where T : WeChatPayNotify
         {
             if (request == null)

+ 1 - 1
src/Essensoft.Paylink.WeChatPay/V2/WeChatPayNotifyResult.cs

@@ -1,4 +1,4 @@
-#if NETCOREAPP3_1 || NET5_0
+#if NETCOREAPP3_1_OR_GREATER
 
 using Microsoft.AspNetCore.Mvc;
 

+ 6 - 0
src/Essensoft.Paylink.WeChatPay/V3/Extensions/HttpClientExtensions.cs

@@ -6,6 +6,7 @@ using System.Net.Http.Headers;
 using System.Text;
 using System.Text.Encodings.Web;
 using System.Text.Json;
+using System.Text.Json.Serialization;
 using System.Threading.Tasks;
 using Essensoft.Paylink.Security;
 
@@ -13,7 +14,12 @@ namespace Essensoft.Paylink.WeChatPay.V3.Extensions
 {
     public static class HttpClientExtensions
     {
+
+#if NET6_0_OR_GREATER
+        private static readonly JsonSerializerOptions jsonSerializerOptions = new() { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping };
+#else
         private static readonly JsonSerializerOptions jsonSerializerOptions = new() { IgnoreNullValues = true, Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping };
+#endif
 
         public static async Task<(WeChatPayHeaders headers, string body, int statusCode)> GetAsync<T>(this HttpClient client, IWeChatPayGetRequest<T> request, WeChatPayOptions options) where T : WeChatPayResponse
         {

+ 1 - 1
src/Essensoft.Paylink.WeChatPay/V3/IWeChatPayNotifyClient.cs

@@ -7,7 +7,7 @@ namespace Essensoft.Paylink.WeChatPay.V3
     /// </summary>
     public interface IWeChatPayNotifyClient
     {
-#if NETCOREAPP3_1 || NET5_0
+#if NETCOREAPP3_1_OR_GREATER
         /// <summary>
         /// 执行 WeChatPay V3 通知请求解析
         /// </summary>

+ 6 - 0
src/Essensoft.Paylink.WeChatPay/V3/Parser/WeChatPayNotifyJsonParser.cs

@@ -1,6 +1,7 @@
 using System;
 using System.Text.Encodings.Web;
 using System.Text.Json;
+using System.Text.Json.Serialization;
 using Essensoft.Paylink.Security;
 using Essensoft.Paylink.WeChatPay.V3.Domain;
 
@@ -8,7 +9,12 @@ namespace Essensoft.Paylink.WeChatPay.V3.Parser
 {
     public class WeChatPayNotifyJsonParser<T> where T : WeChatPayNotify
     {
+
+#if NET6_0_OR_GREATER
+        private static readonly JsonSerializerOptions jsonSerializerOptions = new() { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping };
+#else
         private static readonly JsonSerializerOptions jsonSerializerOptions = new() { IgnoreNullValues = true, Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping };
+#endif
 
         /// <summary>
         /// 将加密报文解密并反序列化

+ 6 - 0
src/Essensoft.Paylink.WeChatPay/V3/Parser/WeChatPayResponseJsonParser.cs

@@ -1,12 +1,18 @@
 using System;
 using System.Text.Encodings.Web;
 using System.Text.Json;
+using System.Text.Json.Serialization;
 
 namespace Essensoft.Paylink.WeChatPay.V3.Parser
 {
     public class WeChatPayResponseJsonParser<T> where T : WeChatPayResponse
     {
+
+#if NET6_0_OR_GREATER
+        private static readonly JsonSerializerOptions jsonSerializerOptions = new() { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping };
+#else
         private static readonly JsonSerializerOptions jsonSerializerOptions = new() { IgnoreNullValues = true, Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping };
+#endif
 
         public T Parse(string body, int statusCode)
         {

+ 1 - 1
src/Essensoft.Paylink.WeChatPay/V3/WeChatPayNotifyClient.cs

@@ -26,7 +26,7 @@ namespace Essensoft.Paylink.WeChatPay.V3
 
         #region IWeChatPayNotifyClient Members
 
-#if NETCOREAPP3_1 || NET5_0
+#if NETCOREAPP3_1_OR_GREATER
         public async Task<T> ExecuteAsync<T>(Microsoft.AspNetCore.Http.HttpRequest request, WeChatPayOptions options) where T : WeChatPayNotify
         {
             if (options == null)

+ 1 - 1
src/Essensoft.Paylink.WeChatPay/V3/WeChatPayNotifyResult.cs

@@ -1,4 +1,4 @@
-#if NETCOREAPP3_1 || NET5_0
+#if NETCOREAPP3_1_OR_GREATER
 
 using Microsoft.AspNetCore.Mvc;