From 645ff16400f4942bd97fcf8d64c632a45f78a4a5 Mon Sep 17 00:00:00 2001 From: jacalvar Date: Thu, 18 Aug 2022 15:34:10 +0200 Subject: [PATCH 1/2] Fix linking issues --- .../Services/RemoteAuthenticationService.cs | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/RemoteAuthenticationService.cs b/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/RemoteAuthenticationService.cs index cfc4f993ead6..d403cfa0e180 100644 --- a/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/RemoteAuthenticationService.cs +++ b/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/RemoteAuthenticationService.cs @@ -31,7 +31,8 @@ public class RemoteAuthenticationService< { private static readonly TimeSpan _userCacheRefreshInterval = TimeSpan.FromSeconds(60); private bool _initialized; - private readonly JavaScriptLoggingOptions _loggingOptions; + + private readonly RemoteAuthenticationServiceJavaScriptLoggingOptions _loggingOptions; // This defaults to 1/1/1970 private DateTimeOffset _userLastCheck = DateTimeOffset.FromUnixTimeSeconds(0); @@ -93,7 +94,11 @@ public RemoteAuthenticationService( Navigation = navigation; AccountClaimsPrincipalFactory = accountClaimsPrincipalFactory; Options = options.Value; - _loggingOptions = new JavaScriptLoggingOptions(logger?.IsEnabled(LogLevel.Debug) ?? false, logger?.IsEnabled(LogLevel.Trace) ?? false); + _loggingOptions = new RemoteAuthenticationServiceJavaScriptLoggingOptions + { + DebugEnabled = logger?.IsEnabled(LogLevel.Debug) ?? false, + TraceEnabled = logger?.IsEnabled(LogLevel.Trace) ?? false + }; } /// @@ -163,6 +168,7 @@ public virtual async ValueTask RequestAccessToken() /// [DynamicDependency(JsonSerialized, typeof(AccessToken))] [DynamicDependency(JsonSerialized, typeof(AccessTokenRequestOptions))] + public virtual async ValueTask RequestAccessToken(AccessTokenRequestOptions options) { if (options is null) @@ -215,6 +221,7 @@ protected internal virtual async ValueTask GetAuthenticatedUser return user; } + [DynamicDependency(JsonSerialized, typeof(RemoteAuthenticationServiceJavaScriptLoggingOptions))] private async ValueTask EnsureAuthService() { if (!_initialized) @@ -240,7 +247,15 @@ private void UpdateUser(Task task) static async Task UpdateAuthenticationState(Task futureUser) => new AuthenticationState(await futureUser); } - private record JavaScriptLoggingOptions(bool DebugEnabled, bool TraceEnabled); +} + +// We need to do this as it can't be nested inside RemoteAuthenticationService because +// it needs to be put in an attribute for linking purposes and that can't be an open generic type. +internal class RemoteAuthenticationServiceJavaScriptLoggingOptions +{ + public bool DebugEnabled { get; set; } + + public bool TraceEnabled { get; set; } } // Internal for testing purposes From b77e45bde7f2af66c251fc7b2e1710e47cccfec7 Mon Sep 17 00:00:00 2001 From: Javier Calvarro Nelson Date: Thu, 25 Aug 2022 11:29:11 +0200 Subject: [PATCH 2/2] Update src/Components/WebAssembly/WebAssembly.Authentication/src/Services/RemoteAuthenticationService.cs Remove additional whitespace --- .../src/Services/RemoteAuthenticationService.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/RemoteAuthenticationService.cs b/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/RemoteAuthenticationService.cs index d403cfa0e180..b5b15c34562b 100644 --- a/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/RemoteAuthenticationService.cs +++ b/src/Components/WebAssembly/WebAssembly.Authentication/src/Services/RemoteAuthenticationService.cs @@ -31,7 +31,6 @@ public class RemoteAuthenticationService< { private static readonly TimeSpan _userCacheRefreshInterval = TimeSpan.FromSeconds(60); private bool _initialized; - private readonly RemoteAuthenticationServiceJavaScriptLoggingOptions _loggingOptions; // This defaults to 1/1/1970