Skip to content

Commit aa73002

Browse files
authored
Add HttpSessionState.Mode (#289)
This change exposes the API and sets it to `Custom`. Everything else has a meaning and implies certain behavior. This value is the only one that makes sense for us to declare. If needed, we can make it customizable later. Fixes #281
1 parent f0199bd commit aa73002

File tree

5 files changed

+41
-0
lines changed

5 files changed

+41
-0
lines changed

src/Microsoft.AspNetCore.SystemWebAdapters/Generated/Ref.Standard.cs

+9
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,7 @@ internal HttpSessionState() { }
569569
public bool IsReadOnly { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
570570
public bool IsSynchronized { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
571571
public object this[string name] { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} set { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
572+
public System.Web.SessionState.SessionStateMode Mode { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
572573
public string SessionID { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
573574
public object SyncRoot { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
574575
public int Timeout { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} set { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} }
@@ -580,4 +581,12 @@ internal HttpSessionState() { }
580581
public void Remove(string name) { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
581582
public void RemoveAll() { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");}
582583
}
584+
public enum SessionStateMode
585+
{
586+
Custom = 4,
587+
InProc = 1,
588+
Off = 0,
589+
SQLServer = 3,
590+
StateServer = 2,
591+
}
583592
}

src/Microsoft.AspNetCore.SystemWebAdapters/Generated/TypeForwards.Framework.cs

+1
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,4 @@
5353
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Web.Caching.CacheItemUpdateReason))]
5454
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Web.Configuration.HttpCapabilitiesBase))]
5555
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Web.SessionState.HttpSessionState))]
56+
[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Web.SessionState.SessionStateMode))]

src/Microsoft.AspNetCore.SystemWebAdapters/SessionState/HttpSessionState.cs

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public int Timeout
3535

3636
public object SyncRoot => _container.SyncRoot;
3737

38+
[Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1822:Mark members as static", Justification = Constants.ApiFromAspNet)]
39+
public SessionStateMode Mode => SessionStateMode.Custom;
40+
3841
public void Abandon() => _container.IsAbandoned = true;
3942

4043
public object? this[string name]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
namespace System.Web.SessionState;
5+
6+
public enum SessionStateMode
7+
{
8+
Off = 0,
9+
InProc = 1,
10+
StateServer = 2,
11+
SQLServer = 3,
12+
Custom = 4
13+
};

test/Microsoft.AspNetCore.SystemWebAdapters.Tests/SessionState/HttpSessionStateTests.cs

+15
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,21 @@ public void SessionId()
3636
Assert.Equal(id, result);
3737
}
3838

39+
[Fact]
40+
public void Mode()
41+
{
42+
// Arrange
43+
var session = new Mock<ISessionState>();
44+
45+
var state = new HttpSessionState(session.Object);
46+
47+
// Act
48+
var result = state.Mode;
49+
50+
// Assert
51+
Assert.Equal(SessionStateMode.Custom, result);
52+
}
53+
3954
[Fact]
4055
public void Count()
4156
{

0 commit comments

Comments
 (0)