From 11395430759d4c510e0ffc8f69b9aeb0cd5c0a6b Mon Sep 17 00:00:00 2001 From: Ezreal Date: Sun, 27 Apr 2025 05:56:22 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=A7=8B=E7=BB=88?= =?UTF-8?q?=E4=B8=8D=E4=B8=BAnull=E7=9A=84=E5=88=A4=E6=96=AD=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Providers/RefParameterDiagnosticProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WebApiClientCore.Analyzers/Providers/RefParameterDiagnosticProvider.cs b/WebApiClientCore.Analyzers/Providers/RefParameterDiagnosticProvider.cs index a8c24384..47dc0c72 100644 --- a/WebApiClientCore.Analyzers/Providers/RefParameterDiagnosticProvider.cs +++ b/WebApiClientCore.Analyzers/Providers/RefParameterDiagnosticProvider.cs @@ -50,7 +50,7 @@ public override IEnumerable CreateDiagnostics() if (declaringSyntax is ParameterSyntax parameterSyntax) { var modifier = parameterSyntax.Modifiers.FirstOrDefault(); - if (modifier != null) + if (modifier != default) { var location = modifier.GetLocation(); yield return this.CreateDiagnostic(location); From eb1ea933ea1d7447bbc42a3fc1d12558b858025a Mon Sep 17 00:00:00 2001 From: Ezreal Date: Sun, 27 Apr 2025 05:59:29 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=87=8D=E5=86=99?= =?UTF-8?q?=E6=88=90=E5=91=98=E4=B8=8E=E6=8E=A5=E5=8F=A3=E6=88=90=E5=91=98?= =?UTF-8?q?=E5=8F=AF=E7=A9=BA=E6=80=A7=E5=AE=9A=E4=B9=89=E4=B8=8D=E4=B8=80?= =?UTF-8?q?=E8=87=B4=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SourceGenerator/HttpApiProxyClass.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/WebApiClientCore.Analyzers/SourceGenerator/HttpApiProxyClass.cs b/WebApiClientCore.Analyzers/SourceGenerator/HttpApiProxyClass.cs index d704f0b1..cae38e59 100644 --- a/WebApiClientCore.Analyzers/SourceGenerator/HttpApiProxyClass.cs +++ b/WebApiClientCore.Analyzers/SourceGenerator/HttpApiProxyClass.cs @@ -166,8 +166,21 @@ private class MethodEqualityComparer : IEqualityComparer { public static MethodEqualityComparer Default { get; } = new MethodEqualityComparer(); - public bool Equals(IMethodSymbol x, IMethodSymbol y) + public bool Equals(IMethodSymbol? x, IMethodSymbol? y) { +#if NET8_0_OR_GREATER + ArgumentNullException.ThrowIfNull(x); + ArgumentNullException.ThrowIfNull(y); +#else + if (x is null) + { + throw new ArgumentNullException(nameof(x)); + } + if (y is null) + { + throw new ArgumentNullException(nameof(y)); + } +#endif if (x.Name != y.Name || !x.ReturnType.Equals(y.ReturnType, SymbolEqualityComparer.Default)) { return false; From 2e1053459631ac55c7d5e3bf6d74d9843fd0bcd0 Mon Sep 17 00:00:00 2001 From: Ezreal Date: Sun, 27 Apr 2025 14:45:43 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=8F=AF=E7=A9=BA=E6=80=A7=E5=BE=AE?= =?UTF-8?q?=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implementations/Tasks/ActionRetryTaskTest.cs | 4 ++-- .../DependencyInjection/NamedHttpApiExtensions.cs | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/WebApiClientCore.Test/Implementations/Tasks/ActionRetryTaskTest.cs b/WebApiClientCore.Test/Implementations/Tasks/ActionRetryTaskTest.cs index dd8a3f67..3c9802f4 100644 --- a/WebApiClientCore.Test/Implementations/Tasks/ActionRetryTaskTest.cs +++ b/WebApiClientCore.Test/Implementations/Tasks/ActionRetryTaskTest.cs @@ -8,11 +8,11 @@ namespace WebApiClientCore.Test.Implementations.Tasks { public class ActionRetryTaskTest { - class ResultApiTask : TaskBase + class ResultApiTask : TaskBase { public T? Result { get; set; } - protected override Task InvokeAsync() + protected override Task InvokeAsync() { return Task.FromResult(Result); } diff --git a/WebApiClientCore/DependencyInjection/NamedHttpApiExtensions.cs b/WebApiClientCore/DependencyInjection/NamedHttpApiExtensions.cs index 7e48d542..7508d871 100644 --- a/WebApiClientCore/DependencyInjection/NamedHttpApiExtensions.cs +++ b/WebApiClientCore/DependencyInjection/NamedHttpApiExtensions.cs @@ -21,8 +21,8 @@ internal static void NamedHttpApiType(this IServiceCollection services, string n services.TryAddSingleton(new NameTypeRegistration()); var descriptor = services.Single(item => item.ServiceType == typeof(NameTypeRegistration)); - var registration = (NameTypeRegistration)descriptor.ImplementationInstance; - registration[name] = httpApiType; + var registration = (NameTypeRegistration?)descriptor.ImplementationInstance; + registration![name] = httpApiType; } /// @@ -38,7 +38,11 @@ internal static void NamedHttpApiType(this IServiceCollection services, string n return null; } - var registration = (NameTypeRegistration)descriptor.ImplementationInstance; + var registration = (NameTypeRegistration?)descriptor.ImplementationInstance; + if (registration == null) + { + return null; + } registration.TryGetValue(builder.Name, out var type); return type; } From a08799a4cdc4c747a25194a2cdf10e2e4205ece2 Mon Sep 17 00:00:00 2001 From: Ezreal Date: Sun, 27 Apr 2025 18:29:57 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=94=AF=E6=8C=81=20.NET=209.0=20=E5=B9=B6?= =?UTF-8?q?=E5=BC=95=E5=85=A5=E5=85=AC=E5=85=B1=E5=B1=9E=E6=80=A7=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增对 .NET 9.0 的支持,更新多个项目的 `TargetFrameworks` 属性以兼容最新框架版本。 引入 `WebApiClientCore.Common.props` 和 `WebApiClientCore.Extensions.Common.props` 公共属性文件,统一管理 `Nullable`、`TargetFrameworks` 等配置,减少重复代码并提升可维护性。 修补风险项 https://github.com/advisories/GHSA-ghhp-997w-qr28 https://github.com/advisories/GHSA-5crp-9r3c-p9vr https://github.com/advisories/GHSA-7jgj-8wvc-jh57 https://github.com/advisories/GHSA-cmhx-cq75-c4mj --- App/App.csproj | 2 +- .../WebApiClientCore.Abstractions.csproj | 8 ++-- .../WebApiClientCore.Analyzers.csproj | 21 +++++----- ...WebApiClientCore.Extensions.JsonRpc.csproj | 4 +- ...lientCore.Extensions.NewtonsoftJson.csproj | 4 +- .../WebApiClientCore.Extensions.OAuths.csproj | 8 ++-- ...ientCore.Extensions.SourceGenerator.csproj | 5 +-- ...iClientCore.OpenApi.SourceGenerator.csproj | 5 ++- .../WebApiClientCore.Test.csproj | 2 +- WebApiClientCore/WebApiClientCore.csproj | 39 ++++++++++++------- props/WebApiClientCore.Common.props | 15 +++++++ .../WebApiClientCore.Extensions.Common.props | 7 ++++ 12 files changed, 76 insertions(+), 44 deletions(-) create mode 100644 props/WebApiClientCore.Common.props create mode 100644 props/WebApiClientCore.Extensions.Common.props diff --git a/App/App.csproj b/App/App.csproj index 91585e3f..5eb3e824 100644 --- a/App/App.csproj +++ b/App/App.csproj @@ -3,7 +3,7 @@ Exe enable - netcoreapp3.0;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0 + netcoreapp3.0;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0 false false diff --git a/WebApiClientCore.Abstractions/WebApiClientCore.Abstractions.csproj b/WebApiClientCore.Abstractions/WebApiClientCore.Abstractions.csproj index db411581..4d4c9116 100644 --- a/WebApiClientCore.Abstractions/WebApiClientCore.Abstractions.csproj +++ b/WebApiClientCore.Abstractions/WebApiClientCore.Abstractions.csproj @@ -1,9 +1,8 @@ + - enable - netstandard2.1;net5.0;net8.0 - true + $(WebApiClientCoreIsAotCompatible) WebApiClientCore WebApiClientCore.Abstractions @@ -19,5 +18,6 @@ + - + \ No newline at end of file diff --git a/WebApiClientCore.Analyzers/WebApiClientCore.Analyzers.csproj b/WebApiClientCore.Analyzers/WebApiClientCore.Analyzers.csproj index 55ddda26..4b29af21 100644 --- a/WebApiClientCore.Analyzers/WebApiClientCore.Analyzers.csproj +++ b/WebApiClientCore.Analyzers/WebApiClientCore.Analyzers.csproj @@ -1,9 +1,7 @@  + - enable - netstandard2.0 - True false false true @@ -11,8 +9,10 @@ - - + + @@ -24,13 +24,16 @@ - - - + ResXFileCodeGenerator Resx.Designer.cs + + ResXFileCodeGenerator + Resx.Designer.cs + Resx.resx + - + \ No newline at end of file diff --git a/WebApiClientCore.Extensions.JsonRpc/WebApiClientCore.Extensions.JsonRpc.csproj b/WebApiClientCore.Extensions.JsonRpc/WebApiClientCore.Extensions.JsonRpc.csproj index 087443e5..53db073e 100644 --- a/WebApiClientCore.Extensions.JsonRpc/WebApiClientCore.Extensions.JsonRpc.csproj +++ b/WebApiClientCore.Extensions.JsonRpc/WebApiClientCore.Extensions.JsonRpc.csproj @@ -1,9 +1,7 @@  + - enable - netstandard2.1 - True true Sign.snk diff --git a/WebApiClientCore.Extensions.NewtonsoftJson/WebApiClientCore.Extensions.NewtonsoftJson.csproj b/WebApiClientCore.Extensions.NewtonsoftJson/WebApiClientCore.Extensions.NewtonsoftJson.csproj index e34ca33b..1da733ec 100644 --- a/WebApiClientCore.Extensions.NewtonsoftJson/WebApiClientCore.Extensions.NewtonsoftJson.csproj +++ b/WebApiClientCore.Extensions.NewtonsoftJson/WebApiClientCore.Extensions.NewtonsoftJson.csproj @@ -1,9 +1,7 @@ + - enable - netstandard2.1 - True true Sign.snk diff --git a/WebApiClientCore.Extensions.OAuths/WebApiClientCore.Extensions.OAuths.csproj b/WebApiClientCore.Extensions.OAuths/WebApiClientCore.Extensions.OAuths.csproj index d9905876..57b2bd15 100644 --- a/WebApiClientCore.Extensions.OAuths/WebApiClientCore.Extensions.OAuths.csproj +++ b/WebApiClientCore.Extensions.OAuths/WebApiClientCore.Extensions.OAuths.csproj @@ -1,10 +1,8 @@ + - enable - True - netstandard2.1;net5.0;net8.0 - true + $(WebApiClientCoreIsAotCompatible) true Sign.snk @@ -16,4 +14,4 @@ - + \ No newline at end of file diff --git a/WebApiClientCore.Extensions.SourceGenerator/WebApiClientCore.Extensions.SourceGenerator.csproj b/WebApiClientCore.Extensions.SourceGenerator/WebApiClientCore.Extensions.SourceGenerator.csproj index c2f35178..57a942ea 100644 --- a/WebApiClientCore.Extensions.SourceGenerator/WebApiClientCore.Extensions.SourceGenerator.csproj +++ b/WebApiClientCore.Extensions.SourceGenerator/WebApiClientCore.Extensions.SourceGenerator.csproj @@ -1,8 +1,7 @@ + + - enable - false - netstandard2.1 true Sign.snk 此扩展包的实现已合并到WebApiClientCore包,无任何功能 diff --git a/WebApiClientCore.OpenApi.SourceGenerator/WebApiClientCore.OpenApi.SourceGenerator.csproj b/WebApiClientCore.OpenApi.SourceGenerator/WebApiClientCore.OpenApi.SourceGenerator.csproj index e4f264f2..59e0ac37 100644 --- a/WebApiClientCore.OpenApi.SourceGenerator/WebApiClientCore.OpenApi.SourceGenerator.csproj +++ b/WebApiClientCore.OpenApi.SourceGenerator/WebApiClientCore.OpenApi.SourceGenerator.csproj @@ -3,7 +3,7 @@ Exe enable - netcoreapp3.1;net6.0;net8.0 + netcoreapp3.1;net6.0;net8.0;net9.0 将本地或远程OpenApi文档解析生成WebApiClientCore的接口定义代码文件的工具 zh-Hans @@ -18,6 +18,9 @@ + + + diff --git a/WebApiClientCore.Test/WebApiClientCore.Test.csproj b/WebApiClientCore.Test/WebApiClientCore.Test.csproj index 9745f1dc..ed26a395 100644 --- a/WebApiClientCore.Test/WebApiClientCore.Test.csproj +++ b/WebApiClientCore.Test/WebApiClientCore.Test.csproj @@ -1,7 +1,7 @@  - net6.0;net8.0 + net6.0;net8.0;net9.0 enable true Test.snk diff --git a/WebApiClientCore/WebApiClientCore.csproj b/WebApiClientCore/WebApiClientCore.csproj index 8e6d8bd3..20011af6 100644 --- a/WebApiClientCore/WebApiClientCore.csproj +++ b/WebApiClientCore/WebApiClientCore.csproj @@ -1,40 +1,49 @@  - + - enable - True - netstandard2.1;net5.0;net8.0 - true + $(WebApiClientCoreIsAotCompatible) .NetCore声明式的Http客户端库 一款基于HttpClient封装,只需要定义c#接口并修饰相关特性,即可异步调用远程http接口的客户端库 true Sign.snk - + - + - + - + + + + + + + - - + + @@ -51,8 +60,10 @@ - + - + - + \ No newline at end of file diff --git a/props/WebApiClientCore.Common.props b/props/WebApiClientCore.Common.props new file mode 100644 index 00000000..d94e89d6 --- /dev/null +++ b/props/WebApiClientCore.Common.props @@ -0,0 +1,15 @@ + + + enable + True + netstandard2.1;net5.0;net8.0;net9.0 + latest + + + false + false + false + true + true + + \ No newline at end of file diff --git a/props/WebApiClientCore.Extensions.Common.props b/props/WebApiClientCore.Extensions.Common.props new file mode 100644 index 00000000..5d7a92bc --- /dev/null +++ b/props/WebApiClientCore.Extensions.Common.props @@ -0,0 +1,7 @@ + + + enable + netstandard2.1 + True + + \ No newline at end of file