From b29dc6beb0d09b8d94afa8c365eeef80e3e1a2b7 Mon Sep 17 00:00:00 2001 From: huoshan12345 Date: Mon, 22 Sep 2025 10:32:21 -0230 Subject: [PATCH 1/2] fix scope for some services to pass the Ms DI's validation --- .../ServiceCollectionExtensions.cs | 4 ++-- .../ServiceCollectionBuildExtensionsTests.cs | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 tests/AspectCore.Extensions.DependencyInjection.Test/ServiceCollectionBuildExtensionsTests.cs diff --git a/src/AspectCore.Extensions.DependencyInjection/ServiceCollectionExtensions.cs b/src/AspectCore.Extensions.DependencyInjection/ServiceCollectionExtensions.cs index 2765b903..5c8e5d8f 100644 --- a/src/AspectCore.Extensions.DependencyInjection/ServiceCollectionExtensions.cs +++ b/src/AspectCore.Extensions.DependencyInjection/ServiceCollectionExtensions.cs @@ -53,10 +53,10 @@ internal static IServiceCollection TryAddDynamicProxyServices(this IServiceColle services.TryAddScoped(); services.TryAddScoped(); services.TryAddScoped(); + services.TryAddScoped(); + services.TryAddScoped(); - services.TryAddSingleton(); services.TryAddSingleton(); - services.TryAddSingleton(); services.TryAddSingleton(); services.TryAddSingleton(); diff --git a/tests/AspectCore.Extensions.DependencyInjection.Test/ServiceCollectionBuildExtensionsTests.cs b/tests/AspectCore.Extensions.DependencyInjection.Test/ServiceCollectionBuildExtensionsTests.cs new file mode 100644 index 00000000..ab80e0dd --- /dev/null +++ b/tests/AspectCore.Extensions.DependencyInjection.Test/ServiceCollectionBuildExtensionsTests.cs @@ -0,0 +1,15 @@ +using Microsoft.Extensions.DependencyInjection; +using Xunit; + +namespace AspectCore.Extensions.DependencyInjection.Test; + +public class ServiceCollectionBuildExtensionsTests +{ + [Fact] + public void BuildDynamicProxyProvider_Validate() + { + var services = new ServiceCollection(); + var provider = services.BuildDynamicProxyProvider(new ServiceProviderOptions { ValidateOnBuild = true, ValidateScopes = true }); + Assert.NotNull(provider); + } +} From 8e253af25846cd8d46082cd97a62d32865891865 Mon Sep 17 00:00:00 2001 From: huoshan12345 Date: Mon, 22 Sep 2025 10:45:58 -0230 Subject: [PATCH 2/2] Install all required versions explicitly --- .github/workflows/build-pr-ci.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-pr-ci.yml b/.github/workflows/build-pr-ci.yml index 3c2ca2bb..6ba6e20d 100644 --- a/.github/workflows/build-pr-ci.yml +++ b/.github/workflows/build-pr-ci.yml @@ -12,8 +12,12 @@ jobs: fetch-depth: 0 - name: Setup .NET Core uses: actions/setup-dotnet@v4 - with: # NOTE: we don't need to install 6.x, 8.x and 9.x cause they are included in windows-latest(windows-2022) image. - dotnet-version: 7.x + with: # Install all required versions explicitly, since some frameworks may be missing from the image if they have been removed due to end of support. + dotnet-version: | + 6.0.x + 7.0.x + 8.0.x + 9.0.x - name: Build Reason run: "echo ref: ${{github.ref}} event: ${{github.event_name}}"