File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -36,6 +36,10 @@ public sealed class DefaultHttpContext : HttpContext
36
36
private DefaultConnectionInfo ? _connection ;
37
37
private DefaultWebSocketManager ? _websockets ;
38
38
39
+ // This is field exists to make analyzing memory dumps easier.
40
+ // https://github.com/dotnet/aspnetcore/issues/29709
41
+ internal bool _active ;
42
+
39
43
/// <summary>
40
44
/// Initializes a new instance of the <see cref="DefaultHttpContext"/> class.
41
45
/// </summary>
@@ -73,6 +77,7 @@ public void Initialize(IFeatureCollection features)
73
77
_response . Initialize ( revision ) ;
74
78
_connection ? . Initialize ( features , revision ) ;
75
79
_websockets ? . Initialize ( features , revision ) ;
80
+ _active = true ;
76
81
}
77
82
78
83
/// <summary>
@@ -85,6 +90,7 @@ public void Uninitialize()
85
90
_response . Uninitialize ( ) ;
86
91
_connection ? . Uninitialize ( ) ;
87
92
_websockets ? . Uninitialize ( ) ;
93
+ _active = false ;
88
94
}
89
95
90
96
/// <summary>
Original file line number Diff line number Diff line change @@ -264,6 +264,22 @@ public async Task RequestServicesAreDisposedAsynOnCompleted()
264
264
Assert . False ( scope . DisposeCalled ) ;
265
265
}
266
266
267
+ [ Fact ]
268
+ public void InternalActiveFlagIsSetAndUnset ( )
269
+ {
270
+ var context = new DefaultHttpContext ( ) ;
271
+
272
+ Assert . False ( context . _active ) ;
273
+
274
+ context . Initialize ( new FeatureCollection ( ) ) ;
275
+
276
+ Assert . True ( context . _active ) ;
277
+
278
+ context . Uninitialize ( ) ;
279
+
280
+ Assert . False ( context . _active ) ;
281
+ }
282
+
267
283
void TestAllCachedFeaturesAreNull ( HttpContext context , IFeatureCollection features )
268
284
{
269
285
TestCachedFeaturesAreNull ( context , features ) ;
You can’t perform that action at this time.
0 commit comments