diff --git a/Samples/ProjectTracker/ProjectTracker.AppServer/ProjectTracker.AppServer.csproj b/Samples/ProjectTracker/ProjectTracker.AppServer/ProjectTracker.AppServer.csproj index 42faed1935..4df4262866 100644 --- a/Samples/ProjectTracker/ProjectTracker.AppServer/ProjectTracker.AppServer.csproj +++ b/Samples/ProjectTracker/ProjectTracker.AppServer/ProjectTracker.AppServer.csproj @@ -7,7 +7,7 @@ - + diff --git a/Samples/ProjectTracker/ProjectTracker.Blazor/ProjectTracker.Blazor.Client/ProjectTracker.Blazor.Client.csproj b/Samples/ProjectTracker/ProjectTracker.Blazor/ProjectTracker.Blazor.Client/ProjectTracker.Blazor.Client.csproj index 25c3cb2e48..abfaec3725 100644 --- a/Samples/ProjectTracker/ProjectTracker.Blazor/ProjectTracker.Blazor.Client/ProjectTracker.Blazor.Client.csproj +++ b/Samples/ProjectTracker/ProjectTracker.Blazor/ProjectTracker.Blazor.Client/ProjectTracker.Blazor.Client.csproj @@ -10,9 +10,9 @@ - - - + + + diff --git a/Samples/ProjectTracker/ProjectTracker.Blazor/ProjectTracker.Blazor/ProjectTracker.Blazor.csproj b/Samples/ProjectTracker/ProjectTracker.Blazor/ProjectTracker.Blazor/ProjectTracker.Blazor.csproj index e21537a753..5cd7969984 100644 --- a/Samples/ProjectTracker/ProjectTracker.Blazor/ProjectTracker.Blazor/ProjectTracker.Blazor.csproj +++ b/Samples/ProjectTracker/ProjectTracker.Blazor/ProjectTracker.Blazor/ProjectTracker.Blazor.csproj @@ -1,4 +1,4 @@ - + net8.0 @@ -12,9 +12,9 @@ - - - + + + diff --git a/Samples/ProjectTracker/ProjectTracker.BusinessLibrary/ProjectTracker.BusinessLibrary.csproj b/Samples/ProjectTracker/ProjectTracker.BusinessLibrary/ProjectTracker.BusinessLibrary.csproj index c78517f5d1..4d6e2beabb 100644 --- a/Samples/ProjectTracker/ProjectTracker.BusinessLibrary/ProjectTracker.BusinessLibrary.csproj +++ b/Samples/ProjectTracker/ProjectTracker.BusinessLibrary/ProjectTracker.BusinessLibrary.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/Samples/ProjectTracker/ProjectTracker.Dal/ProjectTracker.Dal.csproj b/Samples/ProjectTracker/ProjectTracker.Dal/ProjectTracker.Dal.csproj index 30feed3a8c..8ab6e2463a 100644 --- a/Samples/ProjectTracker/ProjectTracker.Dal/ProjectTracker.Dal.csproj +++ b/Samples/ProjectTracker/ProjectTracker.Dal/ProjectTracker.Dal.csproj @@ -7,8 +7,8 @@ - - + + \ No newline at end of file diff --git a/Samples/ProjectTracker/ProjectTracker.DalEfCore/ProjectTracker.DalEfCore.csproj b/Samples/ProjectTracker/ProjectTracker.DalEfCore/ProjectTracker.DalEfCore.csproj index f021091b32..ee1204cc5c 100644 --- a/Samples/ProjectTracker/ProjectTracker.DalEfCore/ProjectTracker.DalEfCore.csproj +++ b/Samples/ProjectTracker/ProjectTracker.DalEfCore/ProjectTracker.DalEfCore.csproj @@ -5,9 +5,9 @@ - - - + + + diff --git a/Samples/ProjectTracker/ProjectTracker.DalMock/ProjectTracker.DalMock.csproj b/Samples/ProjectTracker/ProjectTracker.DalMock/ProjectTracker.DalMock.csproj index a9e529bddf..7a7c6dbb77 100644 --- a/Samples/ProjectTracker/ProjectTracker.DalMock/ProjectTracker.DalMock.csproj +++ b/Samples/ProjectTracker/ProjectTracker.DalMock/ProjectTracker.DalMock.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/Samples/ProjectTracker/global.json b/Samples/ProjectTracker/global.json new file mode 100644 index 0000000000..a679dd12cf --- /dev/null +++ b/Samples/ProjectTracker/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "8.0.401" + } +} \ No newline at end of file diff --git a/Source/Csla.Blazor.Test/AppContext/ContextManagerTests.cs b/Source/Csla.Blazor.Test/AppContext/ContextManagerTests.cs index e273986d73..a56dc99eb9 100644 --- a/Source/Csla.Blazor.Test/AppContext/ContextManagerTests.cs +++ b/Source/Csla.Blazor.Test/AppContext/ContextManagerTests.cs @@ -6,8 +6,11 @@ // Context Manager configuration tests //----------------------------------------------------------------------- +using System.Security.Claims; using Csla.Configuration; using Microsoft.AspNetCore.Components.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Features; using Microsoft.Extensions.DependencyInjection; using Microsoft.VisualStudio.TestTools.UnitTesting; @@ -53,7 +56,42 @@ public void UseApplicationContextManagerBlazor() var applicationContext = serviceProvider.GetRequiredService(); Assert.IsInstanceOfType(applicationContext.ContextManager, typeof(Csla.AspNetCore.Blazor.ApplicationContextManagerBlazor)); + } + + [TestMethod] + public void UseAsyncLocalApplicationContextManager() + { + var services = new ServiceCollection(); + services.AddScoped(); + services.AddHttpContextAccessor(); + services.AddCsla(o => o + .AddAspNetCore() + .AddServerSideBlazor(o => o.UseInMemoryApplicationContextManager = false)); + var serviceProvider = services.BuildServiceProvider(); + + var activeState = serviceProvider.GetRequiredService(); + activeState.CircuitExists = false; + + var applicationContext = serviceProvider.GetRequiredService(); + Assert.IsInstanceOfType(applicationContext.ContextManager, typeof(Csla.Core.ApplicationContextManagerAsyncLocal)); + } + + [TestMethod] + public void UseAspNetCoreApplicationContextManager() + { + var services = new ServiceCollection(); + services.AddScoped(); + services.AddScoped(); + services.AddCsla(o => o + .AddAspNetCore() + .AddServerSideBlazor(o => o.UseInMemoryApplicationContextManager = false)); + var serviceProvider = services.BuildServiceProvider(); + var activeState = serviceProvider.GetRequiredService(); + activeState.CircuitExists = false; + + var applicationContext = serviceProvider.GetRequiredService(); + Assert.IsInstanceOfType(applicationContext.ContextManager, typeof(Csla.AspNetCore.ApplicationContextManagerHttpContext)); } } @@ -65,3 +103,30 @@ public override Task GetAuthenticationStateAsync() throw new System.NotImplementedException(); } } + +public class HttpContextAccessorFake : IHttpContextAccessor +{ + public HttpContext HttpContext { get; set; } = new HttpContextFake(); +} + +public class HttpContextFake : HttpContext +{ + public override IFeatureCollection Features => throw new NotImplementedException(); + + public override HttpRequest Request => throw new NotImplementedException(); + + public override HttpResponse Response => throw new NotImplementedException(); + + public override ConnectionInfo Connection => throw new NotImplementedException(); + + public override WebSocketManager WebSockets => throw new NotImplementedException(); + + public override ClaimsPrincipal User { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } + public override IDictionary Items { get; set; } = new Dictionary(); + public override IServiceProvider RequestServices { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } + public override CancellationToken RequestAborted { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } + public override string TraceIdentifier { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } + public override ISession Session { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } + + public override void Abort() => throw new NotImplementedException(); +} diff --git a/Source/Csla.Blazor/ConfigurationExtensions.cs b/Source/Csla.Blazor/ConfigurationExtensions.cs index 4a586ca285..d1cfe295b3 100644 --- a/Source/Csla.Blazor/ConfigurationExtensions.cs +++ b/Source/Csla.Blazor/ConfigurationExtensions.cs @@ -48,13 +48,7 @@ public static CslaOptions AddServerSideBlazor(this CslaOptions config, Action i.ServiceType.Equals(contextManagerType)).ToList(); - foreach ( var manager in managers ) - config.Services.Remove(manager); + var managerType = Type.GetType(managerTypeName) ?? throw new TypeLoadException(managerTypeName); config.Services.AddScoped(typeof(IContextManager), managerType); if (blazorOptions.UseInMemoryApplicationContextManager) diff --git a/Source/Csla.Xaml.Uwp/Properties/AssemblyInfo.cs b/Source/Csla.Xaml.Uwp/Properties/AssemblyInfo.cs index b35fd1545e..dbe1f94b8a 100644 --- a/Source/Csla.Xaml.Uwp/Properties/AssemblyInfo.cs +++ b/Source/Csla.Xaml.Uwp/Properties/AssemblyInfo.cs @@ -27,5 +27,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("8.2.5.0")] -[assembly: AssemblyFileVersion("8.2.5.0")] \ No newline at end of file +[assembly: AssemblyVersion("8.2.6.0")] +[assembly: AssemblyFileVersion("8.2.6.0")] \ No newline at end of file diff --git a/Source/Directory.Build.props b/Source/Directory.Build.props index fcdad39f93..2a337d9b69 100644 --- a/Source/Directory.Build.props +++ b/Source/Directory.Build.props @@ -6,7 +6,7 @@ - 8.2.5.0 + 8.2.6.0 MIT https://cslanet.com https://github.com/MarimerLLC/csla diff --git a/releasenotes.md b/releasenotes.md index 7a868255ed..ea81c7d90e 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -2,6 +2,18 @@ CSLA 8 is a substantial update to CSLA .NET, adding support for .NET 8 and other enhancements. +## CSLA .NET version 8.2.6 release + +Fixes issues with the way `IContextManager` is resolved in Blazor apps in #4089 and #4182. + +### Change List + +* https://github.com/MarimerLLC/csla/compare/v8.2.5...v8.2.6 + +### Contributors + +* @rockfordlhotka + ## CSLA .NET version 8.2.5 release * [#4075](https://github.com/MarimerLLC/csla/issues/4075) Fix configuration issue with Blazor DI services