Skip to content

Commit c46f84d

Browse files
committed
Annotate WebAssembly.Authentication for nullability
1 parent 274c32e commit c46f84d

28 files changed

+289
-288
lines changed

src/Components/Components/src/NavigationManager.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ protected virtual void EnsureInitialized()
211211
/// </summary>
212212
/// <param name="relativeUri">The relative URI.</param>
213213
/// <returns>The absolute URI.</returns>
214-
public Uri ToAbsoluteUri(string relativeUri)
214+
public Uri ToAbsoluteUri(string? relativeUri)
215215
{
216216
AssertInitialized();
217217
return new Uri(_baseUri!, relativeUri);

src/Components/Components/src/PublicAPI.Unshipped.txt

+2
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,5 @@ static Microsoft.AspNetCore.Components.EventCallbackFactoryBinderExtensions.Crea
5656
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!>
5757
virtual Microsoft.AspNetCore.Components.NavigationManager.HandleLocationChangingHandlerException(System.Exception! ex, Microsoft.AspNetCore.Components.Routing.LocationChangingContext! context) -> void
5858
virtual Microsoft.AspNetCore.Components.NavigationManager.SetNavigationLockState(bool value) -> void
59+
*REMOVED*Microsoft.AspNetCore.Components.NavigationManager.ToAbsoluteUri(string! relativeUri) -> System.Uri!
60+
Microsoft.AspNetCore.Components.NavigationManager.ToAbsoluteUri(string? relativeUri) -> System.Uri!

src/Components/WebAssembly/WebAssembly.Authentication/src/Microsoft.AspNetCore.Components.WebAssembly.Authentication.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
<IsShippingPackage>true</IsShippingPackage>
99
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1010
<IsTrimmable>true</IsTrimmable>
11-
<Nullable>disable</Nullable>
1211
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1312
</PropertyGroup>
1413

src/Components/WebAssembly/WebAssembly.Authentication/src/Models/AccessToken.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class AccessToken
1111
/// <summary>
1212
/// Gets or sets the list of granted scopes for the token.
1313
/// </summary>
14-
public IReadOnlyList<string> GrantedScopes { get; set; }
14+
public IReadOnlyList<string> GrantedScopes { get; set; } = default!;
1515

1616
/// <summary>
1717
/// Gets the expiration time of the token.
@@ -21,5 +21,5 @@ public class AccessToken
2121
/// <summary>
2222
/// Gets the serialized representation of the token.
2323
/// </summary>
24-
public string Value { get; set; }
24+
public string Value { get; set; } = default!;
2525
}

src/Components/WebAssembly/WebAssembly.Authentication/src/Models/InteractiveRequestOptions.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ public sealed class InteractiveRequestOptions
2727
/// <summary>
2828
/// Gets the scopes this request must use in the operation.
2929
/// </summary>
30-
public IEnumerable<string> Scopes { get; init; }
30+
public IEnumerable<string> Scopes { get; init; } = Array.Empty<string>();
3131

32-
private Dictionary<string, object> AdditionalRequestParameters { get; set; }
32+
private Dictionary<string, object>? AdditionalRequestParameters { get; set; }
3333

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

4949
/// <summary>
@@ -58,7 +58,7 @@ public bool TryRemoveAdditionalParameter(string name)
5858
/// <summary>
5959
/// Tries to retrieve an existing additional parameter.
6060
/// </summary>
61-
public bool TryGetAdditionalParameter<[DynamicallyAccessedMembers(JsonSerialized)] TValue>(string name, out TValue value)
61+
public bool TryGetAdditionalParameter<[DynamicallyAccessedMembers(JsonSerialized)] TValue>(string name, out TValue? value)
6262
{
6363
ArgumentNullException.ThrowIfNull(name);
6464

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

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

9191
internal static InteractiveRequestOptions FromState(string state) => JsonSerializer.Deserialize(
9292
state,
93-
InteractiveRequestOptionsSerializerContext.Default.InteractiveRequestOptions);
93+
InteractiveRequestOptionsSerializerContext.Default.InteractiveRequestOptions)!;
9494

9595
internal class Converter : JsonConverter<InteractiveRequestOptions>
9696
{
@@ -119,7 +119,7 @@ internal record struct OptionsRecord(
119119
[property: JsonInclude] string ReturnUrl,
120120
[property: JsonInclude] IEnumerable<string> Scopes,
121121
[property: JsonInclude] InteractionType Interaction,
122-
[property: JsonInclude] Dictionary<string, object> AdditionalRequestParameters);
122+
[property: JsonInclude] Dictionary<string, object>? AdditionalRequestParameters);
123123
}
124124
}
125125

src/Components/WebAssembly/WebAssembly.Authentication/src/Models/RemoteAuthenticationContext.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ public class RemoteAuthenticationContext<[DynamicallyAccessedMembers(JsonSeriali
1515
/// <summary>
1616
/// Gets or sets the url for the current authentication operation.
1717
/// </summary>
18-
public string Url { get; set; }
18+
public string? Url { get; set; }
1919

2020
/// <summary>
2121
/// Gets or sets the state instance for the current authentication operation.
2222
/// </summary>
23-
public TRemoteAuthenticationState State { get; set; }
23+
public TRemoteAuthenticationState? State { get; set; }
2424

2525
/// <summary>
2626
/// Gets or sets the interaction request for the current authentication operation.
2727
/// </summary>
28-
public InteractiveRequestOptions InteractiveRequest { get; set; }
28+
public InteractiveRequestOptions? InteractiveRequest { get; set; }
2929
}

src/Components/WebAssembly/WebAssembly.Authentication/src/Models/RemoteAuthenticationResult.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ public class RemoteAuthenticationResult<TRemoteAuthenticationState> where TRemot
1717
/// <summary>
1818
/// Gets or sets the error message of a failed authentication operation.
1919
/// </summary>
20-
public string ErrorMessage { get; set; }
20+
public string? ErrorMessage { get; set; }
2121

2222
/// <summary>
2323
/// Gets or sets the preserved state of a successful authentication operation.
2424
/// </summary>
25-
public TRemoteAuthenticationState State { get; set; }
25+
public TRemoteAuthenticationState? State { get; set; }
2626
}

src/Components/WebAssembly/WebAssembly.Authentication/src/Models/RemoteAuthenticationState.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ public class RemoteAuthenticationState
1212
/// Gets or sets the URL to which the application should redirect after a successful authentication operation.
1313
/// It must be a url within the page.
1414
/// </summary>
15-
public string ReturnUrl { get; set; }
15+
public string? ReturnUrl { get; set; }
1616
}

src/Components/WebAssembly/WebAssembly.Authentication/src/Models/RemoteUserAccount.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ public class RemoteUserAccount
1717
/// Gets or sets properties not explicitly mapped about the user.
1818
/// </summary>
1919
[JsonExtensionData]
20-
public IDictionary<string, object> AdditionalProperties { get; set; }
20+
public IDictionary<string, object> AdditionalProperties { get; set; } = default!;
2121
}

src/Components/WebAssembly/WebAssembly.Authentication/src/NavigationManagerExtensions.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ public static void NavigateToLogout(this NavigationManager manager, [StringSynta
3232
/// <param name="manager">The <see cref="NavigationManager"/>.</param>
3333
/// <param name="logoutPath">The path to navigate too.</param>
3434
/// <param name="returnUrl">The url to redirect the user to after logging out.</param>
35-
public static void NavigateToLogout(this NavigationManager manager, [StringSyntax(StringSyntaxAttribute.Uri, UriKind.Relative)] string logoutPath, [StringSyntax(StringSyntaxAttribute.Uri)] string returnUrl)
35+
public static void NavigateToLogout(this NavigationManager manager, [StringSyntax(StringSyntaxAttribute.Uri, UriKind.Relative)] string logoutPath, [StringSyntax(StringSyntaxAttribute.Uri)] string? returnUrl)
3636
{
3737
manager.NavigateTo(logoutPath, new NavigationOptions
3838
{
3939
HistoryEntryState = new InteractiveRequestOptions
4040
{
4141
Interaction = InteractionType.SignOut,
42-
ReturnUrl = returnUrl
42+
ReturnUrl = returnUrl!
4343
}.ToState()
4444
});
4545
}

src/Components/WebAssembly/WebAssembly.Authentication/src/Options/ApiAuthorizationProviderOptions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ public class ApiAuthorizationProviderOptions
1111
/// <summary>
1212
/// Gets or sets the endpoint to call to retrieve the authentication settings for the application.
1313
/// </summary>
14-
public string ConfigurationEndpoint { get; set; }
14+
public string? ConfigurationEndpoint { get; set; }
1515
}

src/Components/WebAssembly/WebAssembly.Authentication/src/Options/DefaultApiAuthorizationOptionsConfiguration.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public void Configure(RemoteAuthenticationOptions<ApiAuthorizationProviderOption
2121
options.UserOptions.AuthenticationType ??= _applicationName;
2222
}
2323

24-
public void PostConfigure(string name, RemoteAuthenticationOptions<ApiAuthorizationProviderOptions> options)
24+
public void PostConfigure(string? name, RemoteAuthenticationOptions<ApiAuthorizationProviderOptions> options)
2525
{
2626
if (string.Equals(name, Options.DefaultName))
2727
{

src/Components/WebAssembly/WebAssembly.Authentication/src/Options/DefaultOidcProviderOptionsConfiguration.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public void Configure(RemoteAuthenticationOptions<OidcProviderOptions> options)
3232
}
3333
}
3434

35-
public void PostConfigure(string name, RemoteAuthenticationOptions<OidcProviderOptions> options)
35+
public void PostConfigure(string? name, RemoteAuthenticationOptions<OidcProviderOptions> options)
3636
{
3737
if (string.Equals(name, Options.DefaultName))
3838
{

src/Components/WebAssembly/WebAssembly.Authentication/src/Options/OidcProviderOptions.cs

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ public class OidcProviderOptions
1313
/// <summary>
1414
/// Gets or sets the authority of the OpenID Connect (OIDC) identity provider.
1515
/// </summary>
16-
public string Authority { get; set; }
16+
public string? Authority { get; set; }
1717

1818
/// <summary>
1919
/// Gets or sets the metadata URL of the OpenID Connect (OIDC) provider.
2020
/// </summary>
21-
public string MetadataUrl { get; set; }
21+
public string? MetadataUrl { get; set; }
2222

2323
/// <summary>
2424
/// Gets or sets the client of the application.
2525
/// </summary>
2626
[JsonPropertyName("client_id")]
27-
public string ClientId { get; set; }
27+
public string? ClientId { get; set; }
2828

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

4242
/// <summary>
4343
/// 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
4444
/// process from the identity provider.
4545
/// </summary>
4646
[JsonPropertyName("post_logout_redirect_uri")]
47-
public string PostLogoutRedirectUri { get; set; }
47+
public string? PostLogoutRedirectUri { get; set; }
4848

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

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

6161
/// <summary>
6262
/// Gets or sets the additional provider parameters to use on the authorization flow.

src/Components/WebAssembly/WebAssembly.Authentication/src/Options/RemoteAuthenticationApplicationPathsOptions.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class RemoteAuthenticationApplicationPathsOptions
1717
/// Gets or sets the remote path to the remote endpoint for registering new users.
1818
/// It might be absolute and point outside of the application.
1919
/// </summary>
20-
public string RemoteRegisterPath { get; set; }
20+
public string? RemoteRegisterPath { get; set; }
2121

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

3333
/// <summary>
3434
/// Gets or sets the path to the login page.

src/Components/WebAssembly/WebAssembly.Authentication/src/Options/RemoteAuthenticationUserOptions.cs

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@ public class RemoteAuthenticationUserOptions
1616
/// <summary>
1717
/// Gets or sets the claim type to use for the user roles.
1818
/// </summary>
19-
public string RoleClaim { get; set; }
19+
public string? RoleClaim { get; set; }
2020

2121
/// <summary>
2222
/// Gets or sets the claim type to use for the user scopes.
2323
/// </summary>
24-
public string ScopeClaim { get; set; }
24+
public string? ScopeClaim { get; set; }
2525

2626
/// <summary>
2727
/// Gets or sets the value to use for the <see cref="System.Security.Claims.ClaimsIdentity.AuthenticationType"/>.
2828
/// </summary>
29-
public string AuthenticationType { get; set; }
29+
public string? AuthenticationType { get; set; }
3030
}

0 commit comments

Comments
 (0)