From 966b39383314b9caa6487a95a6566271cd0e9d5f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 4 Aug 2026 17:51:12 +0000 Subject: [PATCH 1/3] Initial plan From 331054818049dc32f1b987588b4d63fbcec9464f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 4 Aug 2026 17:53:18 +0000 Subject: [PATCH 2/3] Clone modulesToLoad array before wrapping in ReadOnlyCollection to prevent aliasing Co-authored-by: damyanpetev <3198469+damyanpetev@users.noreply.github.com> --- src/componentsBase/InfragisticsBlazorExtensions.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/componentsBase/InfragisticsBlazorExtensions.cs b/src/componentsBase/InfragisticsBlazorExtensions.cs index 1fc5519..6bd58f8 100644 --- a/src/componentsBase/InfragisticsBlazorExtensions.cs +++ b/src/componentsBase/InfragisticsBlazorExtensions.cs @@ -36,7 +36,8 @@ public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddIgn (sp) => { var bs = new IgniteUIBlazorSettings(); - bs = bs.WithModulesToLoad(modulesToLoad != null && modulesToLoad.Length > 0 ? new ReadOnlyCollection(modulesToLoad) : null); + Type[] modules = modulesToLoad != null && modulesToLoad.Length > 0 ? [.. modulesToLoad] : []; + bs = bs.WithModulesToLoad(modules.Length > 0 ? new ReadOnlyCollection(modules) : null); return bs; }); From b2cf8371d79b67cdb75eb2d831b626d33f16483a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 6 Aug 2026 12:18:21 +0000 Subject: [PATCH 3/3] fix(AddIgniteUIBlazor): snapshot modulesToLoad before lambda and add aliasing test Co-authored-by: damyanpetev <3198469+damyanpetev@users.noreply.github.com> --- .../InfragisticsBlazorExtensions.cs | 6 ++++-- .../ServiceRegistrationTests.cs | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/componentsBase/InfragisticsBlazorExtensions.cs b/src/componentsBase/InfragisticsBlazorExtensions.cs index 6bd58f8..df3c742 100644 --- a/src/componentsBase/InfragisticsBlazorExtensions.cs +++ b/src/componentsBase/InfragisticsBlazorExtensions.cs @@ -31,13 +31,15 @@ public static class InfragisticsBlazorExtensions public static Microsoft.Extensions.DependencyInjection.IServiceCollection AddIgniteUIBlazor(this Microsoft.Extensions.DependencyInjection.IServiceCollection collection, params Type[] modulesToLoad) { + // Snapshot the caller's array immediately so any later mutation has no effect. + Type[] snapshot = modulesToLoad != null && modulesToLoad.Length > 0 ? [.. modulesToLoad] : []; + var s = collection.AddScoped( typeof(IIgniteUIBlazorSettings), (sp) => { var bs = new IgniteUIBlazorSettings(); - Type[] modules = modulesToLoad != null && modulesToLoad.Length > 0 ? [.. modulesToLoad] : []; - bs = bs.WithModulesToLoad(modules.Length > 0 ? new ReadOnlyCollection(modules) : null); + bs = bs.WithModulesToLoad(snapshot.Length > 0 ? new ReadOnlyCollection(snapshot) : null); return bs; }); diff --git a/tests/IgniteUI.Blazor.Tests/ServiceRegistrationTests.cs b/tests/IgniteUI.Blazor.Tests/ServiceRegistrationTests.cs index af251c5..5a2bbd9 100644 --- a/tests/IgniteUI.Blazor.Tests/ServiceRegistrationTests.cs +++ b/tests/IgniteUI.Blazor.Tests/ServiceRegistrationTests.cs @@ -163,6 +163,23 @@ public void Runtime_InvokesRegisterOnEveryListedModule() Assert.Same(runtime, Assert.Single(SecondModule.Registrations)); } + /// + /// Mutating the original array after calling AddIgniteUIBlazor must not change which + /// modules the settings report. The overload snapshots the array at registration time. + /// + [Fact] + public void AddIgniteUIBlazor_MutatingOriginalArray_DoesNotAffectRegisteredModules() + { + var modules = new Type[] { typeof(FirstModule) }; + + using var host = new Host(s => s.AddIgniteUIBlazor(modules)); + + // Mutate after registration, before the first resolve. + modules[0] = typeof(SecondModule); + + Assert.Equal([typeof(FirstModule)], SettingsOf(host).ModulesToLoad); + } + [Fact] public void Runtime_IsScoped_SoEachScopeRegistersItsOwn() {