From d746faf3fc29903c5e1636fe516ef4fc10872774 Mon Sep 17 00:00:00 2001 From: Taylor Southwick Date: Mon, 16 Oct 2023 09:43:59 -0700 Subject: [PATCH 1/2] Use AddWrappedAspNetCoreSession to better fit standard naming We have a method (WrapAsnnetCoreSession) that wraps the ASP.NET Core session for use with System.Web.SessionState APIs, but this name is not in line with the standard service collection extensions of (`Add...`). This change obsoletes the old one and applies the normal convention. --- samples/CoreApp/Program.cs | 2 +- .../Wrapped/ISystemWebAdapterBuilderSessionExtensions.cs | 4 ++++ .../SessionState/SessionIntegrationTests.cs | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/samples/CoreApp/Program.cs b/samples/CoreApp/Program.cs index 725058e36f..1bd4945f43 100644 --- a/samples/CoreApp/Program.cs +++ b/samples/CoreApp/Program.cs @@ -1,7 +1,7 @@ var builder = WebApplication.CreateBuilder(); builder.Services.AddSystemWebAdapters() - .WrapAspNetCoreSession() + .AddWrappedAspNetCoreSession() .AddSessionSerializer() .AddCustomSerialization(); diff --git a/src/Microsoft.AspNetCore.SystemWebAdapters.CoreServices/SessionState/Wrapped/ISystemWebAdapterBuilderSessionExtensions.cs b/src/Microsoft.AspNetCore.SystemWebAdapters.CoreServices/SessionState/Wrapped/ISystemWebAdapterBuilderSessionExtensions.cs index 6c72f24e2b..881bc8c5a4 100644 --- a/src/Microsoft.AspNetCore.SystemWebAdapters.CoreServices/SessionState/Wrapped/ISystemWebAdapterBuilderSessionExtensions.cs +++ b/src/Microsoft.AspNetCore.SystemWebAdapters.CoreServices/SessionState/Wrapped/ISystemWebAdapterBuilderSessionExtensions.cs @@ -12,7 +12,11 @@ namespace Microsoft.Extensions.DependencyInjection; public static class ISystemWebAdapterBuilderSessionExtensions { + [Obsolete("Prefer AddWrappedAspNetCoreSession instead")] public static ISystemWebAdapterBuilder WrapAspNetCoreSession(this ISystemWebAdapterBuilder builder, Action? options = null) + => builder.AddWrappedAspNetCoreSession(options); + + public static ISystemWebAdapterBuilder AddWrappedAspNetCoreSession(this ISystemWebAdapterBuilder builder, Action? options = null) { ArgumentNullException.ThrowIfNull(builder); diff --git a/test/Microsoft.AspNetCore.SystemWebAdapters.CoreServices.Tests/SessionState/SessionIntegrationTests.cs b/test/Microsoft.AspNetCore.SystemWebAdapters.CoreServices.Tests/SessionState/SessionIntegrationTests.cs index 0c095d68d1..08411de6d4 100644 --- a/test/Microsoft.AspNetCore.SystemWebAdapters.CoreServices.Tests/SessionState/SessionIntegrationTests.cs +++ b/test/Microsoft.AspNetCore.SystemWebAdapters.CoreServices.Tests/SessionState/SessionIntegrationTests.cs @@ -66,7 +66,7 @@ private static async Task GetAsync(string endpoint) services.AddRouting(); services.AddControllers(); services.AddSystemWebAdapters() - .WrapAspNetCoreSession(); + .AddWrappedAspNetCoreSession(); services.AddDistributedMemoryCache(); }) .Configure(app => From 107b641b3f55eaa2c190852e7740bbda045aee45 Mon Sep 17 00:00:00 2001 From: Taylor Southwick Date: Mon, 16 Oct 2023 09:46:45 -0700 Subject: [PATCH 2/2] hide from intellisense --- .../Wrapped/ISystemWebAdapterBuilderSessionExtensions.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Microsoft.AspNetCore.SystemWebAdapters.CoreServices/SessionState/Wrapped/ISystemWebAdapterBuilderSessionExtensions.cs b/src/Microsoft.AspNetCore.SystemWebAdapters.CoreServices/SessionState/Wrapped/ISystemWebAdapterBuilderSessionExtensions.cs index 881bc8c5a4..91fb398fc8 100644 --- a/src/Microsoft.AspNetCore.SystemWebAdapters.CoreServices/SessionState/Wrapped/ISystemWebAdapterBuilderSessionExtensions.cs +++ b/src/Microsoft.AspNetCore.SystemWebAdapters.CoreServices/SessionState/Wrapped/ISystemWebAdapterBuilderSessionExtensions.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.ComponentModel; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.SystemWebAdapters; using Microsoft.AspNetCore.SystemWebAdapters.SessionState.Serialization; @@ -13,6 +14,7 @@ namespace Microsoft.Extensions.DependencyInjection; public static class ISystemWebAdapterBuilderSessionExtensions { [Obsolete("Prefer AddWrappedAspNetCoreSession instead")] + [EditorBrowsable(EditorBrowsableState.Never)] public static ISystemWebAdapterBuilder WrapAspNetCoreSession(this ISystemWebAdapterBuilder builder, Action? options = null) => builder.AddWrappedAspNetCoreSession(options);