Skip to content

[Blazor] Fix linking issues #43515

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 26, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ 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);
Expand Down Expand Up @@ -93,7 +93,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
};
}

/// <inheritdoc />
Expand Down Expand Up @@ -163,6 +167,7 @@ public virtual async ValueTask<AccessTokenResult> RequestAccessToken()
/// <inheritdoc />
[DynamicDependency(JsonSerialized, typeof(AccessToken))]
[DynamicDependency(JsonSerialized, typeof(AccessTokenRequestOptions))]

public virtual async ValueTask<AccessTokenResult> RequestAccessToken(AccessTokenRequestOptions options)
{
if (options is null)
Expand Down Expand Up @@ -215,6 +220,7 @@ protected internal virtual async ValueTask<ClaimsPrincipal> GetAuthenticatedUser
return user;
}

[DynamicDependency(JsonSerialized, typeof(RemoteAuthenticationServiceJavaScriptLoggingOptions))]
private async ValueTask EnsureAuthService()
{
if (!_initialized)
Expand All @@ -240,7 +246,15 @@ private void UpdateUser(Task<ClaimsPrincipal> task)
static async Task<AuthenticationState> UpdateAuthenticationState(Task<ClaimsPrincipal> 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
Expand Down