From 5390fcb9a29f03b28bcbb2b39e5dbd49d2ab1d72 Mon Sep 17 00:00:00 2001 From: Stuart Turner Date: Thu, 4 Jun 2026 09:11:03 -0500 Subject: [PATCH] Fix registration --- .../Templates/ServiceCollectionExtensions.sbntxt | 2 ++ .../Immediate.Cache.FunctionalTests/ApplicationCacheTests.cs | 5 +---- ...sNotGenerate#IC.ServiceCollectionExtensions.g.verified.cs | 1 + ...sNotGenerate#IC.ServiceCollectionExtensions.g.verified.cs | 1 + ...sNotGenerate#IC.ServiceCollectionExtensions.g.verified.cs | 1 + ...s.ValidCache#IC.ServiceCollectionExtensions.g.verified.cs | 2 ++ ...AssemblyName#IC.ServiceCollectionExtensions.g.verified.cs | 2 ++ 7 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Immediate.Cache.Generators/Templates/ServiceCollectionExtensions.sbntxt b/src/Immediate.Cache.Generators/Templates/ServiceCollectionExtensions.sbntxt index 83c03c4..ce5ba6a 100644 --- a/src/Immediate.Cache.Generators/Templates/ServiceCollectionExtensions.sbntxt +++ b/src/Immediate.Cache.Generators/Templates/ServiceCollectionExtensions.sbntxt @@ -18,6 +18,7 @@ public static partial class CacheServiceCollectionExtensions global::Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionDescriptorExtensions.Add( services, global::Microsoft.Extensions.DependencyInjection.ServiceDescriptor.Singleton( + typeof(global::{{~ if !string.empty c.namespace; c.namespace; "."; end }}{{ c.class_name }}), typeof(global::{{~ if !string.empty c.namespace; c.namespace; "."; end }}{{ c.class_name }}) ) ); @@ -26,6 +27,7 @@ public static partial class CacheServiceCollectionExtensions global::Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionDescriptorExtensions.TryAdd( services, global::Microsoft.Extensions.DependencyInjection.ServiceDescriptor.Singleton( + typeof(global::Immediate.Cache.Shared.Owned<>), typeof(global::Immediate.Cache.Shared.Owned<>) ) ); diff --git a/tests/Immediate.Cache.FunctionalTests/ApplicationCacheTests.cs b/tests/Immediate.Cache.FunctionalTests/ApplicationCacheTests.cs index 3bb9f48..bdfc2ca 100644 --- a/tests/Immediate.Cache.FunctionalTests/ApplicationCacheTests.cs +++ b/tests/Immediate.Cache.FunctionalTests/ApplicationCacheTests.cs @@ -1,4 +1,3 @@ -using Immediate.Cache.Shared; using Microsoft.Extensions.Caching.Memory; using Microsoft.Extensions.DependencyInjection; using Xunit; @@ -12,10 +11,8 @@ public sealed class ApplicationCacheTests public ApplicationCacheTests() { var services = new ServiceCollection(); + _ = services.AddImmediateCacheFunctionalTestsCaches(); _ = services.AddImmediateCacheFunctionalTestsHandlers(); - _ = services.AddSingleton(); - _ = services.AddSingleton(); - _ = services.AddSingleton(typeof(Owned<>)); _ = services.AddMemoryCache(); _serviceProvider = services.BuildServiceProvider(); diff --git a/tests/Immediate.Cache.Tests/GeneratorTests/Snapshots/CacheGenerationTests.InvalidHandlerReturn_DoesNotGenerate#IC.ServiceCollectionExtensions.g.verified.cs b/tests/Immediate.Cache.Tests/GeneratorTests/Snapshots/CacheGenerationTests.InvalidHandlerReturn_DoesNotGenerate#IC.ServiceCollectionExtensions.g.verified.cs index 76b1d3b..5607c6f 100644 --- a/tests/Immediate.Cache.Tests/GeneratorTests/Snapshots/CacheGenerationTests.InvalidHandlerReturn_DoesNotGenerate#IC.ServiceCollectionExtensions.g.verified.cs +++ b/tests/Immediate.Cache.Tests/GeneratorTests/Snapshots/CacheGenerationTests.InvalidHandlerReturn_DoesNotGenerate#IC.ServiceCollectionExtensions.g.verified.cs @@ -13,6 +13,7 @@ public static partial class CacheServiceCollectionExtensions global::Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionDescriptorExtensions.TryAdd( services, global::Microsoft.Extensions.DependencyInjection.ServiceDescriptor.Singleton( + typeof(global::Immediate.Cache.Shared.Owned<>), typeof(global::Immediate.Cache.Shared.Owned<>) ) ); diff --git a/tests/Immediate.Cache.Tests/GeneratorTests/Snapshots/CacheGenerationTests.NotHandler_DoesNotGenerate#IC.ServiceCollectionExtensions.g.verified.cs b/tests/Immediate.Cache.Tests/GeneratorTests/Snapshots/CacheGenerationTests.NotHandler_DoesNotGenerate#IC.ServiceCollectionExtensions.g.verified.cs index 76b1d3b..5607c6f 100644 --- a/tests/Immediate.Cache.Tests/GeneratorTests/Snapshots/CacheGenerationTests.NotHandler_DoesNotGenerate#IC.ServiceCollectionExtensions.g.verified.cs +++ b/tests/Immediate.Cache.Tests/GeneratorTests/Snapshots/CacheGenerationTests.NotHandler_DoesNotGenerate#IC.ServiceCollectionExtensions.g.verified.cs @@ -13,6 +13,7 @@ public static partial class CacheServiceCollectionExtensions global::Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionDescriptorExtensions.TryAdd( services, global::Microsoft.Extensions.DependencyInjection.ServiceDescriptor.Singleton( + typeof(global::Immediate.Cache.Shared.Owned<>), typeof(global::Immediate.Cache.Shared.Owned<>) ) ); diff --git a/tests/Immediate.Cache.Tests/GeneratorTests/Snapshots/CacheGenerationTests.StaticHandler_DoesNotGenerate#IC.ServiceCollectionExtensions.g.verified.cs b/tests/Immediate.Cache.Tests/GeneratorTests/Snapshots/CacheGenerationTests.StaticHandler_DoesNotGenerate#IC.ServiceCollectionExtensions.g.verified.cs index 76b1d3b..5607c6f 100644 --- a/tests/Immediate.Cache.Tests/GeneratorTests/Snapshots/CacheGenerationTests.StaticHandler_DoesNotGenerate#IC.ServiceCollectionExtensions.g.verified.cs +++ b/tests/Immediate.Cache.Tests/GeneratorTests/Snapshots/CacheGenerationTests.StaticHandler_DoesNotGenerate#IC.ServiceCollectionExtensions.g.verified.cs @@ -13,6 +13,7 @@ public static partial class CacheServiceCollectionExtensions global::Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionDescriptorExtensions.TryAdd( services, global::Microsoft.Extensions.DependencyInjection.ServiceDescriptor.Singleton( + typeof(global::Immediate.Cache.Shared.Owned<>), typeof(global::Immediate.Cache.Shared.Owned<>) ) ); diff --git a/tests/Immediate.Cache.Tests/GeneratorTests/Snapshots/CacheGenerationTests.ValidCache#IC.ServiceCollectionExtensions.g.verified.cs b/tests/Immediate.Cache.Tests/GeneratorTests/Snapshots/CacheGenerationTests.ValidCache#IC.ServiceCollectionExtensions.g.verified.cs index d365bdc..36f5b9d 100644 --- a/tests/Immediate.Cache.Tests/GeneratorTests/Snapshots/CacheGenerationTests.ValidCache#IC.ServiceCollectionExtensions.g.verified.cs +++ b/tests/Immediate.Cache.Tests/GeneratorTests/Snapshots/CacheGenerationTests.ValidCache#IC.ServiceCollectionExtensions.g.verified.cs @@ -13,6 +13,7 @@ public static partial class CacheServiceCollectionExtensions global::Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionDescriptorExtensions.Add( services, global::Microsoft.Extensions.DependencyInjection.ServiceDescriptor.Singleton( + typeof(global::Dummy.GetUsersQueryCache), typeof(global::Dummy.GetUsersQueryCache) ) ); @@ -20,6 +21,7 @@ public static partial class CacheServiceCollectionExtensions global::Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionDescriptorExtensions.TryAdd( services, global::Microsoft.Extensions.DependencyInjection.ServiceDescriptor.Singleton( + typeof(global::Immediate.Cache.Shared.Owned<>), typeof(global::Immediate.Cache.Shared.Owned<>) ) ); diff --git a/tests/Immediate.Cache.Tests/GeneratorTests/Snapshots/ImmediateAssemblyIdentifierTests.ImmediateAssemblyIdentifierOverridesAssemblyName#IC.ServiceCollectionExtensions.g.verified.cs b/tests/Immediate.Cache.Tests/GeneratorTests/Snapshots/ImmediateAssemblyIdentifierTests.ImmediateAssemblyIdentifierOverridesAssemblyName#IC.ServiceCollectionExtensions.g.verified.cs index 523338a..be0a64a 100644 --- a/tests/Immediate.Cache.Tests/GeneratorTests/Snapshots/ImmediateAssemblyIdentifierTests.ImmediateAssemblyIdentifierOverridesAssemblyName#IC.ServiceCollectionExtensions.g.verified.cs +++ b/tests/Immediate.Cache.Tests/GeneratorTests/Snapshots/ImmediateAssemblyIdentifierTests.ImmediateAssemblyIdentifierOverridesAssemblyName#IC.ServiceCollectionExtensions.g.verified.cs @@ -13,6 +13,7 @@ public static partial class CacheServiceCollectionExtensions global::Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionDescriptorExtensions.Add( services, global::Microsoft.Extensions.DependencyInjection.ServiceDescriptor.Singleton( + typeof(global::Dummy.GetUsersQueryCache), typeof(global::Dummy.GetUsersQueryCache) ) ); @@ -20,6 +21,7 @@ public static partial class CacheServiceCollectionExtensions global::Microsoft.Extensions.DependencyInjection.Extensions.ServiceCollectionDescriptorExtensions.TryAdd( services, global::Microsoft.Extensions.DependencyInjection.ServiceDescriptor.Singleton( + typeof(global::Immediate.Cache.Shared.Owned<>), typeof(global::Immediate.Cache.Shared.Owned<>) ) );