Skip to content

Commit 8cb2e7d

Browse files
committed
Cleanups
1 parent 3149951 commit 8cb2e7d

File tree

9 files changed

+24
-72
lines changed

9 files changed

+24
-72
lines changed

src/Components/Components/src/PersistentState/PersistentValueProviderComponentSubscription.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ private void RestoreProperty()
113113
}
114114

115115
// The key needs to be computed here, do not move this outside of the lambda.
116-
_storageKey ??= PersistentStateKeyResolver.ComputeKey(_subscriber, _propertyName);
116+
_storageKey ??= PersistentStateValueProviderKeyResolver.ComputeKey(_subscriber, _propertyName);
117117

118118
if (_customSerializer != null)
119119
{
@@ -159,7 +159,7 @@ private void RestoreProperty()
159159
private Task PersistProperty()
160160
{
161161
// The key needs to be computed here, do not move this outside of the lambda.
162-
_storageKey ??= PersistentStateKeyResolver.ComputeKey(_subscriber, _propertyName);
162+
_storageKey ??= PersistentStateValueProviderKeyResolver.ComputeKey(_subscriber, _propertyName);
163163

164164
var property = _propertyGetter.GetValue(_subscriber.Component);
165165
if (property == null)

src/Components/Components/test/ComponentStatePersistenceManagerFilteringTests.cs

Whitespace-only changes.

src/Components/Endpoints/src/Rendering/Buffering/TextChunk.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System.Diagnostics;
5-
using System.Globalization;
64
using System.Text;
75

86
namespace Microsoft.AspNetCore.Components.Endpoints.Rendering;
97

108
// Holds different types of outputs that can be written to BufferedTextWriter
11-
12-
[DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")]
139
internal readonly struct TextChunk
1410
{
1511
private readonly TextChunkType _type;
@@ -78,16 +74,4 @@ public Task WriteToAsync(TextWriter writer, string charArraySegments, ref String
7874
}
7975

8076
private enum TextChunkType { Int, String, Char, CharArraySegment };
81-
82-
internal string GetDebuggerDisplay()
83-
{
84-
return _type switch
85-
{
86-
TextChunkType.String => _stringValue!,
87-
TextChunkType.Char => $"{_charValue}",
88-
TextChunkType.CharArraySegment => "<<Buffer>>",
89-
TextChunkType.Int => _intValue.ToString(CultureInfo.InvariantCulture),
90-
_ => throw new NotImplementedException(),
91-
};
92-
}
9377
}

src/Components/Endpoints/src/Rendering/Buffering/TextChunkPage.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System.Diagnostics;
5-
using System.Text;
6-
74
namespace Microsoft.AspNetCore.Components.Endpoints.Rendering;
85

96
// Used internally by TextChunkListBuilder
10-
[DebuggerDisplay($"{{{nameof(GetDebuggerDisplay)}(),nq}}")]
117
internal class TextChunkPage
128
{
139
private readonly TextChunk[] _buffer;
@@ -44,15 +40,4 @@ public void Clear()
4440
{
4541
_count = 0;
4642
}
47-
48-
private string GetDebuggerDisplay()
49-
{
50-
var sb = new StringBuilder();
51-
for (var i = 0; i < _count; i++)
52-
{
53-
sb.Append(_buffer[i].GetDebuggerDisplay());
54-
}
55-
56-
return sb.ToString();
57-
}
5843
}

src/Components/Endpoints/src/Rendering/EndpointComponentState.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33

44
using System.Collections.Concurrent;
5-
using System.Diagnostics;
65
using System.Reflection;
76
using System.Reflection.Metadata;
87
using Microsoft.AspNetCore.Components.Endpoints;
@@ -20,7 +19,6 @@ internal sealed class EndpointComponentState : ComponentState
2019
public EndpointComponentState(Renderer renderer, int componentId, IComponent component, ComponentState? parentComponentState)
2120
: base(renderer, componentId, component, parentComponentState)
2221
{
23-
Debug.Assert(renderer != null && renderer is EndpointHtmlRenderer);
2422
_renderer = (EndpointHtmlRenderer)renderer;
2523

2624
var streamRenderingAttribute = _streamRenderingAttributeByComponentType.GetOrAdd(component.GetType(),

src/Components/test/E2ETest/Tests/StatePersistenceTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ public void CanRenderComponentWithPersistedState(bool suppressEnhancedNavigation
117117
// For server we validate that the state is provided every time a circuit is initialized.
118118
[Theory]
119119
[InlineData(typeof(InteractiveServerRenderMode), (string)null)]
120-
[InlineData(typeof(InteractiveServerRenderMode), "ServerStreaming")]
120+
[InlineData(typeof(InteractiveServerRenderMode), "ServerStreaming", Skip = "https://github.com/dotnet/aspnetcore/issues/62828")]
121121
[InlineData(typeof(InteractiveWebAssemblyRenderMode), (string)null)]
122-
[InlineData(typeof(InteractiveWebAssemblyRenderMode), "WebAssemblyStreaming", Skip = "Streaming not yet supported")]
122+
[InlineData(typeof(InteractiveWebAssemblyRenderMode), "WebAssemblyStreaming", Skip = "https://github.com/dotnet/aspnetcore/issues/62828")]
123123
[InlineData(typeof(InteractiveAutoRenderMode), (string)null)]
124-
[InlineData(typeof(InteractiveAutoRenderMode), "AutoStreaming", Skip = "Streaming not yet supported")]
124+
[InlineData(typeof(InteractiveAutoRenderMode), "AutoStreaming", Skip = "https://github.com/dotnet/aspnetcore/issues/62828")]
125125
public void CanUpdateComponentsWithPersistedStateAndEnhancedNavUpdates(
126126
Type renderMode,
127127
string streaming)

src/Components/test/testassets/Components.TestServer/RazorComponentEndpointsStartup.cs

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4-
using System.Diagnostics;
54
using System.Globalization;
65
using System.Reflection;
76
using System.Security.Claims;
@@ -32,39 +31,31 @@ public RazorComponentEndpointsStartup(IConfiguration configuration)
3231
public void ConfigureServices(IServiceCollection services)
3332
{
3433
services.AddValidation();
35-
if (Debugger.IsAttached)
36-
{
37-
services.AddSignalR(options =>
38-
{
39-
options.KeepAliveInterval = TimeSpan.FromMinutes(10); // default is 15 seconds
40-
options.ClientTimeoutInterval = TimeSpan.FromMinutes(20); // must be longer than KeepAliveInterval
41-
});
42-
}
4334

4435
services.AddRazorComponents(options =>
4536
{
4637
options.MaxFormMappingErrorCount = 10;
4738
options.MaxFormMappingRecursionDepth = 5;
4839
options.MaxFormMappingCollectionSize = 100;
4940
})
50-
.RegisterPersistentService<InteractiveServerService>(RenderMode.InteractiveServer)
51-
.RegisterPersistentService<InteractiveAutoService>(RenderMode.InteractiveAuto)
52-
.RegisterPersistentService<InteractiveWebAssemblyService>(RenderMode.InteractiveWebAssembly)
53-
.AddInteractiveWebAssemblyComponents()
54-
.AddInteractiveServerComponents(options =>
55-
{
56-
if (Configuration.GetValue<bool>("DisableReconnectionCache"))
41+
.RegisterPersistentService<InteractiveServerService>(RenderMode.InteractiveServer)
42+
.RegisterPersistentService<InteractiveAutoService>(RenderMode.InteractiveAuto)
43+
.RegisterPersistentService<InteractiveWebAssemblyService>(RenderMode.InteractiveWebAssembly)
44+
.AddInteractiveWebAssemblyComponents()
45+
.AddInteractiveServerComponents(options =>
5746
{
58-
// This disables the reconnection cache, which forces the server to persist the circuit state.
59-
options.DisconnectedCircuitMaxRetained = 0;
60-
options.DetailedErrors = true;
61-
}
62-
})
63-
.AddAuthenticationStateSerialization(options =>
64-
{
65-
bool.TryParse(Configuration["SerializeAllClaims"], out var serializeAllClaims);
66-
options.SerializeAllClaims = serializeAllClaims;
67-
});
47+
if (Configuration.GetValue<bool>("DisableReconnectionCache"))
48+
{
49+
// This disables the reconnection cache, which forces the server to persist the circuit state.
50+
options.DisconnectedCircuitMaxRetained = 0;
51+
options.DetailedErrors = true;
52+
}
53+
})
54+
.AddAuthenticationStateSerialization(options =>
55+
{
56+
bool.TryParse(Configuration["SerializeAllClaims"], out var serializeAllClaims);
57+
options.SerializeAllClaims = serializeAllClaims;
58+
});
6859

6960
if (Configuration.GetValue<bool>("UseHybridCache"))
7061
{

src/Components/test/testassets/Components.TestServer/appsettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
},
1414
"Console": {
1515
"LogLevel": {
16-
"Default": "Debug"
16+
"Default": "Warning"
1717
}
1818
}
1919
}

src/Components/test/testassets/TestContentPackage/PersistentComponents/NonStreamingComponentWithPersistentState.razor

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
<p id="interactive-runtime">Interactive runtime: @_interactiveRuntime</p>
77
<p id="state-found">State found:@_stateFound</p>
88
<p id="state-value">State value:@_stateValue</p>
9-
<p id="enhanced-nav-state">Enhanced nav state:@EnhancedNavState</p>
109

1110
@code {
1211

@@ -16,14 +15,9 @@
1615

1716
[Inject] public PersistentComponentState PersistentComponentState { get; set; }
1817

19-
[CascadingParameter(Name = nameof(RunningOnServer))]
20-
public bool RunningOnServer { get; set; }
21-
18+
[CascadingParameter(Name = nameof(RunningOnServer))] public bool RunningOnServer { get; set; }
2219
[Parameter] public string ServerState { get; set; }
2320

24-
[PersistentState(AllowUpdates = true)]
25-
public string EnhancedNavState { get; set; }
26-
2721
protected override void OnInitialized()
2822
{
2923
PersistentComponentState.RegisterOnPersisting(PersistState);

0 commit comments

Comments
 (0)