Skip to content

Commit ed423dc

Browse files
authored
Annotate WebAssembly.Authentication (#39838)
* Annotate WebAssembly.Authentication Fixes #30751 Fixes #35162
1 parent d3ce404 commit ed423dc

10 files changed

+68
-21
lines changed

src/Components/WebAssembly/Authentication.Msal/src/MsalWebAssemblyServiceCollectionExtensions.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ public static IRemoteAuthenticationBuilder<RemoteAuthenticationState, RemoteUser
3535
/// <param name="services">The <see cref="IServiceCollection"/>.</param>
3636
/// <param name="configure">A callback to configure the <see cref="RemoteAuthenticationOptions{MsalProviderOptions}"/>.</param>
3737
/// <returns>The <see cref="IServiceCollection"/>.</returns>
38-
public static IRemoteAuthenticationBuilder<TRemoteAuthenticationState, RemoteUserAccount> AddMsalAuthentication<TRemoteAuthenticationState>(this IServiceCollection services, Action<RemoteAuthenticationOptions<MsalProviderOptions>> configure)
38+
public static IRemoteAuthenticationBuilder<TRemoteAuthenticationState, RemoteUserAccount> AddMsalAuthentication<
39+
[DynamicallyAccessedMembers(JsonSerialized)] TRemoteAuthenticationState>(
40+
this IServiceCollection services, Action<RemoteAuthenticationOptions<MsalProviderOptions>> configure)
3941
where TRemoteAuthenticationState : RemoteAuthenticationState, new()
4042
{
4143
return AddMsalAuthentication<TRemoteAuthenticationState, RemoteUserAccount>(services, configure);
@@ -49,7 +51,9 @@ public static IRemoteAuthenticationBuilder<TRemoteAuthenticationState, RemoteUse
4951
/// <param name="services">The <see cref="IServiceCollection"/>.</param>
5052
/// <param name="configure">A callback to configure the <see cref="RemoteAuthenticationOptions{MsalProviderOptions}"/>.</param>
5153
/// <returns>The <see cref="IServiceCollection"/>.</returns>
52-
public static IRemoteAuthenticationBuilder<TRemoteAuthenticationState, TAccount> AddMsalAuthentication<TRemoteAuthenticationState, [DynamicallyAccessedMembers(JsonSerialized)] TAccount>(this IServiceCollection services, Action<RemoteAuthenticationOptions<MsalProviderOptions>> configure)
54+
public static IRemoteAuthenticationBuilder<TRemoteAuthenticationState, TAccount> AddMsalAuthentication<
55+
[DynamicallyAccessedMembers(JsonSerialized)] TRemoteAuthenticationState, [DynamicallyAccessedMembers(JsonSerialized)] TAccount>(
56+
this IServiceCollection services, Action<RemoteAuthenticationOptions<MsalProviderOptions>> configure)
5357
where TRemoteAuthenticationState : RemoteAuthenticationState, new()
5458
where TAccount : RemoteUserAccount
5559
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<linker>
3+
<assembly fullname="Microsoft.AspNetCore.Components.WebAssembly.Authentication, Version=42.42.42.42, Culture=neutral, PublicKeyToken=adb9793829ddae60">
4+
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
5+
<argument>ILLink</argument>
6+
<argument>IL2091</argument>
7+
<property name="Scope">member</property>
8+
<property name="Target">F:Microsoft.Extensions.DependencyInjection.WebAssemblyAuthenticationServiceCollectionExtensions.&lt;&gt;c__1`1.&lt;&gt;9__1_0</property>
9+
</attribute>
10+
<attribute fullname="System.Diagnostics.CodeAnalysis.UnconditionalSuppressMessageAttribute">
11+
<argument>ILLink</argument>
12+
<argument>IL2091</argument>
13+
<property name="Scope">member</property>
14+
<property name="Target">M:Microsoft.Extensions.DependencyInjection.WebAssemblyAuthenticationServiceCollectionExtensions.&lt;&gt;c__1`1.&lt;AddAuthenticationStateProvider&gt;b__1_0(System.IServiceProvider)</property>
15+
</attribute>
16+
</assembly>
17+
</linker>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
<Description>Build client-side authentication for single-page applications (SPAs).</Description>
88
<IsShippingPackage>true</IsShippingPackage>
99
<GenerateDocumentationFile>true</GenerateDocumentationFile>
10+
<Trimmable>true</Trimmable>
1011
<Nullable>disable</Nullable>
1112
</PropertyGroup>
1213

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Diagnostics.CodeAnalysis;
5+
using static Microsoft.AspNetCore.Internal.LinkerFlags;
6+
47
namespace Microsoft.AspNetCore.Components.WebAssembly.Authentication;
58

69
/// <summary>
710
/// Represents the context during authentication operations.
811
/// </summary>
912
/// <typeparam name="TRemoteAuthenticationState"></typeparam>
10-
public class RemoteAuthenticationContext<TRemoteAuthenticationState> where TRemoteAuthenticationState : RemoteAuthenticationState
13+
public class RemoteAuthenticationContext<[DynamicallyAccessedMembers(JsonSerialized)] TRemoteAuthenticationState> where TRemoteAuthenticationState : RemoteAuthenticationState
1114
{
1215
/// <summary>
1316
/// Gets or sets the url for the current authentication operation.

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Diagnostics.CodeAnalysis;
5+
using static Microsoft.AspNetCore.Internal.LinkerFlags;
6+
47
namespace Microsoft.AspNetCore.Components.WebAssembly.Authentication;
58

69
/// <summary>
710
/// Options for remote authentication.
811
/// </summary>
912
/// <typeparam name="TRemoteAuthenticationProviderOptions">The type of the underlying provider options.</typeparam>
10-
public class RemoteAuthenticationOptions<TRemoteAuthenticationProviderOptions> where TRemoteAuthenticationProviderOptions : new()
13+
public class RemoteAuthenticationOptions<[DynamicallyAccessedMembers(JsonSerialized)] TRemoteAuthenticationProviderOptions> where TRemoteAuthenticationProviderOptions : new()
1114
{
1215
/// <summary>
1316
/// Gets or sets the provider options.

src/Components/WebAssembly/WebAssembly.Authentication/src/RemoteAuthenticatorViewCore.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Diagnostics.CodeAnalysis;
45
using Microsoft.AspNetCore.Components.Authorization;
56
using Microsoft.AspNetCore.Components.Rendering;
67
using Microsoft.JSInterop;
8+
using static Microsoft.AspNetCore.Internal.LinkerFlags;
79

810
namespace Microsoft.AspNetCore.Components.WebAssembly.Authentication;
911

1012
/// <summary>
1113
/// A component that handles remote authentication operations in an application.
1214
/// </summary>
1315
/// <typeparam name="TAuthenticationState">The user state type persisted while the operation is in progress. It must be serializable.</typeparam>
14-
public class RemoteAuthenticatorViewCore<TAuthenticationState> : ComponentBase where TAuthenticationState : RemoteAuthenticationState
16+
public class RemoteAuthenticatorViewCore<[DynamicallyAccessedMembers(JsonSerialized)] TAuthenticationState> : ComponentBase where TAuthenticationState : RemoteAuthenticationState
1517
{
1618
private string _message;
1719
private RemoteAuthenticationApplicationPathsOptions _applicationPaths;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Diagnostics.CodeAnalysis;
45
using Microsoft.Extensions.Options;
6+
using static Microsoft.AspNetCore.Internal.LinkerFlags;
57

68
namespace Microsoft.AspNetCore.Components.WebAssembly.Authentication;
79

8-
internal class DefaultRemoteApplicationPathsProvider<TProviderOptions> : IRemoteAuthenticationPathsProvider where TProviderOptions : class, new()
10+
internal class DefaultRemoteApplicationPathsProvider<[DynamicallyAccessedMembers(JsonSerialized)] TProviderOptions> : IRemoteAuthenticationPathsProvider where TProviderOptions : class, new()
911
{
1012
private readonly IOptions<RemoteAuthenticationOptions<TProviderOptions>> _options;
1113

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Diagnostics.CodeAnalysis;
5+
using static Microsoft.AspNetCore.Internal.LinkerFlags;
6+
47
namespace Microsoft.AspNetCore.Components.WebAssembly.Authentication;
58

69
/// <summary>
710
/// Represents a contract for services that perform authentication operations for a Blazor WebAssembly application.
811
/// </summary>
912
/// <typeparam name="TRemoteAuthenticationState">The state to be persisted across authentication operations.</typeparam>
10-
public interface IRemoteAuthenticationService<TRemoteAuthenticationState>
13+
public interface IRemoteAuthenticationService<[DynamicallyAccessedMembers(JsonSerialized)] TRemoteAuthenticationState>
1114
where TRemoteAuthenticationState : RemoteAuthenticationState
1215
{
1316
/// <summary>

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ namespace Microsoft.AspNetCore.Components.WebAssembly.Authentication;
1616
/// <typeparam name="TRemoteAuthenticationState">The state to preserve across authentication operations.</typeparam>
1717
/// <typeparam name="TAccount">The type of the <see cref="RemoteUserAccount" />.</typeparam>
1818
/// <typeparam name="TProviderOptions">The options to be passed down to the underlying JavaScript library handling the authentication operations.</typeparam>
19-
public class RemoteAuthenticationService<TRemoteAuthenticationState, [DynamicallyAccessedMembers(JsonSerialized)] TAccount, TProviderOptions> :
19+
public class RemoteAuthenticationService<
20+
[DynamicallyAccessedMembers(JsonSerialized)] TRemoteAuthenticationState,
21+
[DynamicallyAccessedMembers(JsonSerialized)] TAccount,
22+
[DynamicallyAccessedMembers(JsonSerialized)] TProviderOptions> :
2023
AuthenticationStateProvider,
2124
IRemoteAuthenticationService<TRemoteAuthenticationState>,
2225
IAccessTokenProvider
@@ -162,6 +165,7 @@ public virtual async ValueTask<AccessTokenResult> RequestAccessToken()
162165
}
163166

164167
/// <inheritdoc />
168+
[DynamicDependency(JsonSerialized, typeof(AccessTokenRequestOptions))]
165169
public virtual async ValueTask<AccessTokenResult> RequestAccessToken(AccessTokenRequestOptions options)
166170
{
167171
if (options is null)

0 commit comments

Comments
 (0)