Skip to content

Annotate WebAssembly.Authentication for nullability #43442

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 3 commits into from
Nov 14, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion src/Components/Components/src/NavigationManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ protected virtual void EnsureInitialized()
/// </summary>
/// <param name="relativeUri">The relative URI.</param>
/// <returns>The absolute URI.</returns>
public Uri ToAbsoluteUri(string relativeUri)
public Uri ToAbsoluteUri(string? relativeUri)
{
AssertInitialized();
return new Uri(_baseUri!, relativeUri);
Expand Down
2 changes: 2 additions & 0 deletions src/Components/Components/src/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,5 @@ static Microsoft.AspNetCore.Components.EventCallbackFactoryBinderExtensions.Crea
static Microsoft.AspNetCore.Components.EventCallbackFactoryBinderExtensions.CreateBinder<T>(this Microsoft.AspNetCore.Components.EventCallbackFactory! factory, object! receiver, Microsoft.AspNetCore.Components.EventCallback<T> setter, T existingValue, System.Globalization.CultureInfo? culture = null) -> Microsoft.AspNetCore.Components.EventCallback<Microsoft.AspNetCore.Components.ChangeEventArgs!>
virtual Microsoft.AspNetCore.Components.NavigationManager.HandleLocationChangingHandlerException(System.Exception! ex, Microsoft.AspNetCore.Components.Routing.LocationChangingContext! context) -> void
virtual Microsoft.AspNetCore.Components.NavigationManager.SetNavigationLockState(bool value) -> void
*REMOVED*Microsoft.AspNetCore.Components.NavigationManager.ToAbsoluteUri(string! relativeUri) -> System.Uri!
Microsoft.AspNetCore.Components.NavigationManager.ToAbsoluteUri(string? relativeUri) -> System.Uri!
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<IsShippingPackage>true</IsShippingPackage>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<IsTrimmable>true</IsTrimmable>
<Nullable>disable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class AccessToken
/// <summary>
/// Gets or sets the list of granted scopes for the token.
/// </summary>
public IReadOnlyList<string> GrantedScopes { get; set; }
public IReadOnlyList<string> GrantedScopes { get; set; } = default!;

/// <summary>
/// Gets the expiration time of the token.
Expand All @@ -21,5 +21,5 @@ public class AccessToken
/// <summary>
/// Gets the serialized representation of the token.
/// </summary>
public string Value { get; set; }
public string Value { get; set; } = default!;
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public sealed class InteractiveRequestOptions
/// <summary>
/// Gets the scopes this request must use in the operation.
/// </summary>
public IEnumerable<string> Scopes { get; init; }
public IEnumerable<string> Scopes { get; init; } = Array.Empty<string>();

private Dictionary<string, object> AdditionalRequestParameters { get; set; }
private Dictionary<string, object>? AdditionalRequestParameters { get; set; }

/// <summary>
/// Tries to add an additional parameter to pass in to the underlying provider.
Expand All @@ -43,7 +43,7 @@ public sealed class InteractiveRequestOptions
{
ArgumentNullException.ThrowIfNull(name, nameof(name));
AdditionalRequestParameters ??= new();
return AdditionalRequestParameters.TryAdd(name, value);
return AdditionalRequestParameters.TryAdd(name, value!);
}

/// <summary>
Expand All @@ -58,7 +58,7 @@ public bool TryRemoveAdditionalParameter(string name)
/// <summary>
/// Tries to retrieve an existing additional parameter.
/// </summary>
public bool TryGetAdditionalParameter<[DynamicallyAccessedMembers(JsonSerialized)] TValue>(string name, out TValue value)
public bool TryGetAdditionalParameter<[DynamicallyAccessedMembers(JsonSerialized)] TValue>(string name, [NotNullWhen(true)] out TValue? value)
{
ArgumentNullException.ThrowIfNull(name);

Expand All @@ -69,7 +69,7 @@ public bool TryRemoveAdditionalParameter(string name)
}
if (rawValue is JsonElement json)
{
value = Deserialize(json);
value = Deserialize(json)!;
AdditionalRequestParameters[name] = value;
return true;
}
Expand All @@ -83,14 +83,14 @@ public bool TryRemoveAdditionalParameter(string name)
"Trimming",
"IL2026:Members annotated with 'RequiresUnreferencedCodeAttribute' require dynamic access otherwise can break functionality when trimming application code",
Justification = "The types this method deserializes are anotated with 'DynamicallyAccessedMembers' to prevent them from being linked out as part of 'TryAddAdditionalParameter'.")]
static TValue Deserialize(JsonElement element) => element.Deserialize<TValue>();
static TValue Deserialize(JsonElement element) => element.Deserialize<TValue>()!;
}

internal string ToState() => JsonSerializer.Serialize(this, InteractiveRequestOptionsSerializerContext.Default.InteractiveRequestOptions);

internal static InteractiveRequestOptions FromState(string state) => JsonSerializer.Deserialize(
state,
InteractiveRequestOptionsSerializerContext.Default.InteractiveRequestOptions);
InteractiveRequestOptionsSerializerContext.Default.InteractiveRequestOptions)!;

internal class Converter : JsonConverter<InteractiveRequestOptions>
{
Expand Down Expand Up @@ -119,7 +119,7 @@ internal record struct OptionsRecord(
[property: JsonInclude] string ReturnUrl,
[property: JsonInclude] IEnumerable<string> Scopes,
[property: JsonInclude] InteractionType Interaction,
[property: JsonInclude] Dictionary<string, object> AdditionalRequestParameters);
[property: JsonInclude] Dictionary<string, object>? AdditionalRequestParameters);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ public class RemoteAuthenticationContext<[DynamicallyAccessedMembers(JsonSeriali
/// <summary>
/// Gets or sets the url for the current authentication operation.
/// </summary>
public string Url { get; set; }
public string? Url { get; set; }

/// <summary>
/// Gets or sets the state instance for the current authentication operation.
/// </summary>
public TRemoteAuthenticationState State { get; set; }
public TRemoteAuthenticationState? State { get; set; }

/// <summary>
/// Gets or sets the interaction request for the current authentication operation.
/// </summary>
public InteractiveRequestOptions InteractiveRequest { get; set; }
public InteractiveRequestOptions? InteractiveRequest { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ public class RemoteAuthenticationResult<TRemoteAuthenticationState> where TRemot
/// <summary>
/// Gets or sets the error message of a failed authentication operation.
/// </summary>
public string ErrorMessage { get; set; }
public string? ErrorMessage { get; set; }

/// <summary>
/// Gets or sets the preserved state of a successful authentication operation.
/// </summary>
public TRemoteAuthenticationState State { get; set; }
public TRemoteAuthenticationState? State { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ public class RemoteAuthenticationState
/// Gets or sets the URL to which the application should redirect after a successful authentication operation.
/// It must be a url within the page.
/// </summary>
public string ReturnUrl { get; set; }
public string? ReturnUrl { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ public class RemoteUserAccount
/// Gets or sets properties not explicitly mapped about the user.
/// </summary>
[JsonExtensionData]
public IDictionary<string, object> AdditionalProperties { get; set; }
public IDictionary<string, object> AdditionalProperties { get; set; } = default!;
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ public static void NavigateToLogout(this NavigationManager manager, [StringSynta
/// <param name="manager">The <see cref="NavigationManager"/>.</param>
/// <param name="logoutPath">The path to navigate too.</param>
/// <param name="returnUrl">The url to redirect the user to after logging out.</param>
public static void NavigateToLogout(this NavigationManager manager, [StringSyntax(StringSyntaxAttribute.Uri, UriKind.Relative)] string logoutPath, [StringSyntax(StringSyntaxAttribute.Uri)] string returnUrl)
public static void NavigateToLogout(this NavigationManager manager, [StringSyntax(StringSyntaxAttribute.Uri, UriKind.Relative)] string logoutPath, [StringSyntax(StringSyntaxAttribute.Uri)] string? returnUrl)
{
manager.NavigateTo(logoutPath, new NavigationOptions
{
HistoryEntryState = new InteractiveRequestOptions
{
Interaction = InteractionType.SignOut,
ReturnUrl = returnUrl
ReturnUrl = returnUrl!
}.ToState()
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ public class ApiAuthorizationProviderOptions
/// <summary>
/// Gets or sets the endpoint to call to retrieve the authentication settings for the application.
/// </summary>
public string ConfigurationEndpoint { get; set; }
public string? ConfigurationEndpoint { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public void Configure(RemoteAuthenticationOptions<ApiAuthorizationProviderOption
options.UserOptions.AuthenticationType ??= _applicationName;
}

public void PostConfigure(string name, RemoteAuthenticationOptions<ApiAuthorizationProviderOptions> options)
public void PostConfigure(string? name, RemoteAuthenticationOptions<ApiAuthorizationProviderOptions> options)
{
if (string.Equals(name, Options.DefaultName))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void Configure(RemoteAuthenticationOptions<OidcProviderOptions> options)
}
}

public void PostConfigure(string name, RemoteAuthenticationOptions<OidcProviderOptions> options)
public void PostConfigure(string? name, RemoteAuthenticationOptions<OidcProviderOptions> options)
{
if (string.Equals(name, Options.DefaultName))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ public class OidcProviderOptions
/// <summary>
/// Gets or sets the authority of the OpenID Connect (OIDC) identity provider.
/// </summary>
public string Authority { get; set; }
public string? Authority { get; set; }

/// <summary>
/// Gets or sets the metadata URL of the OpenID Connect (OIDC) provider.
/// </summary>
public string MetadataUrl { get; set; }
public string? MetadataUrl { get; set; }

/// <summary>
/// Gets or sets the client of the application.
/// </summary>
[JsonPropertyName("client_id")]
public string ClientId { get; set; }
public string? ClientId { get; set; }

/// <summary>
/// Gets or sets the list of scopes to request when signing in.
Expand All @@ -37,26 +37,26 @@ public class OidcProviderOptions
/// process from the identity provider.
/// </summary>
[JsonPropertyName("redirect_uri")]
public string RedirectUri { get; set; }
public string? RedirectUri { get; set; }

/// <summary>
/// Gets or sets the post logout redirect URI for the application. The application will be redirected here after the user has completed the sign out
/// process from the identity provider.
/// </summary>
[JsonPropertyName("post_logout_redirect_uri")]
public string PostLogoutRedirectUri { get; set; }
public string? PostLogoutRedirectUri { get; set; }

/// <summary>
/// Gets or sets the response type to use on the authorization flow. The valid values are specified by the identity provider metadata.
/// </summary>
[JsonPropertyName("response_type")]
public string ResponseType { get; set; }
public string? ResponseType { get; set; }

/// <summary>
/// Gets or sets the response mode to use in the authorization flow.
/// </summary>
[JsonPropertyName("response_mode")]
public string ResponseMode { get; set; }
public string? ResponseMode { get; set; }

/// <summary>
/// Gets or sets the additional provider parameters to use on the authorization flow.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class RemoteAuthenticationApplicationPathsOptions
/// Gets or sets the remote path to the remote endpoint for registering new users.
/// It might be absolute and point outside of the application.
/// </summary>
public string RemoteRegisterPath { get; set; }
public string? RemoteRegisterPath { get; set; }

/// <summary>
/// Gets or sets the path to the endpoint for modifying the settings for the user profile.
Expand All @@ -28,7 +28,7 @@ public class RemoteAuthenticationApplicationPathsOptions
/// Gets or sets the path to the remote endpoint for modifying the settings for the user profile.
/// It might be absolute and point outside of the application.
/// </summary>
public string RemoteProfilePath { get; set; }
public string? RemoteProfilePath { get; set; }

/// <summary>
/// Gets or sets the path to the login page.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ public class RemoteAuthenticationUserOptions
/// <summary>
/// Gets or sets the claim type to use for the user roles.
/// </summary>
public string RoleClaim { get; set; }
public string? RoleClaim { get; set; }

/// <summary>
/// Gets or sets the claim type to use for the user scopes.
/// </summary>
public string ScopeClaim { get; set; }
public string? ScopeClaim { get; set; }

/// <summary>
/// Gets or sets the value to use for the <see cref="System.Security.Claims.ClaimsIdentity.AuthenticationType"/>.
/// </summary>
public string AuthenticationType { get; set; }
public string? AuthenticationType { get; set; }
}
Loading