Skip to content

Commit 35bd1e2

Browse files
authored
[Blazor] Fix linking issues (#43515)
Replaces a record used internally for serialization with a class as there were some issues with the parameter names from the record constructor being stripped.
1 parent 1e6d8c9 commit 35bd1e2

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/Components/WebAssembly/WebAssembly.Authentication/src/Services/RemoteAuthenticationService.cs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class RemoteAuthenticationService<
3131
{
3232
private static readonly TimeSpan _userCacheRefreshInterval = TimeSpan.FromSeconds(60);
3333
private bool _initialized;
34-
private readonly JavaScriptLoggingOptions _loggingOptions;
34+
private readonly RemoteAuthenticationServiceJavaScriptLoggingOptions _loggingOptions;
3535

3636
// This defaults to 1/1/1970
3737
private DateTimeOffset _userLastCheck = DateTimeOffset.FromUnixTimeSeconds(0);
@@ -93,7 +93,11 @@ public RemoteAuthenticationService(
9393
Navigation = navigation;
9494
AccountClaimsPrincipalFactory = accountClaimsPrincipalFactory;
9595
Options = options.Value;
96-
_loggingOptions = new JavaScriptLoggingOptions(logger?.IsEnabled(LogLevel.Debug) ?? false, logger?.IsEnabled(LogLevel.Trace) ?? false);
96+
_loggingOptions = new RemoteAuthenticationServiceJavaScriptLoggingOptions
97+
{
98+
DebugEnabled = logger?.IsEnabled(LogLevel.Debug) ?? false,
99+
TraceEnabled = logger?.IsEnabled(LogLevel.Trace) ?? false
100+
};
97101
}
98102

99103
/// <inheritdoc />
@@ -163,6 +167,7 @@ public virtual async ValueTask<AccessTokenResult> RequestAccessToken()
163167
/// <inheritdoc />
164168
[DynamicDependency(JsonSerialized, typeof(AccessToken))]
165169
[DynamicDependency(JsonSerialized, typeof(AccessTokenRequestOptions))]
170+
166171
public virtual async ValueTask<AccessTokenResult> RequestAccessToken(AccessTokenRequestOptions options)
167172
{
168173
if (options is null)
@@ -215,6 +220,7 @@ protected internal virtual async ValueTask<ClaimsPrincipal> GetAuthenticatedUser
215220
return user;
216221
}
217222

223+
[DynamicDependency(JsonSerialized, typeof(RemoteAuthenticationServiceJavaScriptLoggingOptions))]
218224
private async ValueTask EnsureAuthService()
219225
{
220226
if (!_initialized)
@@ -240,7 +246,15 @@ private void UpdateUser(Task<ClaimsPrincipal> task)
240246
static async Task<AuthenticationState> UpdateAuthenticationState(Task<ClaimsPrincipal> futureUser) => new AuthenticationState(await futureUser);
241247
}
242248

243-
private record JavaScriptLoggingOptions(bool DebugEnabled, bool TraceEnabled);
249+
}
250+
251+
// We need to do this as it can't be nested inside RemoteAuthenticationService because
252+
// it needs to be put in an attribute for linking purposes and that can't be an open generic type.
253+
internal class RemoteAuthenticationServiceJavaScriptLoggingOptions
254+
{
255+
public bool DebugEnabled { get; set; }
256+
257+
public bool TraceEnabled { get; set; }
244258
}
245259

246260
// Internal for testing purposes

0 commit comments

Comments
 (0)