Skip to content

Commit ef6286f

Browse files
authored
Enable trimming on remaining middleware and security projects (#41688)
1 parent 374896b commit ef6286f

25 files changed

+87
-24
lines changed

eng/TrimmableProjects.props

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<TrimmableProject Include="Microsoft.AspNetCore.DataProtection.EntityFrameworkCore" />
1515
<TrimmableProject Include="Microsoft.AspNetCore.DataProtection.Extensions" />
1616
<TrimmableProject Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" />
17+
<TrimmableProject Include="Microsoft.AspNetCore.Antiforgery" />
1718
<TrimmableProject Include="Microsoft.AspNetCore.Hosting.Abstractions" />
1819
<TrimmableProject Include="Microsoft.AspNetCore.Hosting" />
1920
<TrimmableProject Include="Microsoft.AspNetCore.Hosting.Server.Abstractions" />
@@ -37,7 +38,21 @@
3738
<TrimmableProject Include="Microsoft.AspNetCore.Server.Kestrel" />
3839
<TrimmableProject Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Quic" />
3940
<TrimmableProject Include="Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets" />
41+
<TrimmableProject Include="Microsoft.AspNetCore.Authentication.Certificate" />
42+
<TrimmableProject Include="Microsoft.AspNetCore.Authentication.Cookies" />
43+
<TrimmableProject Include="Microsoft.AspNetCore.Authentication" />
44+
<TrimmableProject Include="Microsoft.AspNetCore.Authentication.Facebook" />
45+
<TrimmableProject Include="Microsoft.AspNetCore.Authentication.Google" />
46+
<TrimmableProject Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
47+
<TrimmableProject Include="Microsoft.AspNetCore.Authentication.MicrosoftAccount" />
48+
<TrimmableProject Include="Microsoft.AspNetCore.Authentication.Negotiate" />
49+
<TrimmableProject Include="Microsoft.AspNetCore.Authentication.OAuth" />
50+
<TrimmableProject Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" />
51+
<TrimmableProject Include="Microsoft.AspNetCore.Authentication.Twitter" />
52+
<TrimmableProject Include="Microsoft.AspNetCore.Authentication.WsFederation" />
4053
<TrimmableProject Include="Microsoft.AspNetCore.Authorization" />
54+
<TrimmableProject Include="Microsoft.AspNetCore.Authorization.Policy" />
55+
<TrimmableProject Include="Microsoft.AspNetCore.CookiePolicy" />
4156
<TrimmableProject Include="Microsoft.AspNetCore.Cors" />
4257
<TrimmableProject Include="Microsoft.AspNetCore.Diagnostics.Abstractions" />
4358
<TrimmableProject Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" />
@@ -56,6 +71,7 @@
5671
<TrimmableProject Include="Microsoft.AspNetCore.ResponseCaching" />
5772
<TrimmableProject Include="Microsoft.AspNetCore.ResponseCompression" />
5873
<TrimmableProject Include="Microsoft.AspNetCore.Rewrite" />
74+
<TrimmableProject Include="Microsoft.AspNetCore.Session" />
5975
<TrimmableProject Include="Microsoft.AspNetCore.SpaProxy" />
6076
<TrimmableProject Include="Microsoft.AspNetCore.SpaServices.Extensions" />
6177
<TrimmableProject Include="Microsoft.AspNetCore.StaticFiles" />

src/Antiforgery/src/Microsoft.AspNetCore.Antiforgery.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>
88
<PackageTags>aspnetcore;antiforgery</PackageTags>
99
<IsPackable>false</IsPackable>
10-
<Nullable>enable</Nullable>
10+
<IsTrimmable>true</IsTrimmable>
1111
</PropertyGroup>
1212

1313
<ItemGroup>

src/Middleware/Session/src/Microsoft.AspNetCore.Session.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<GenerateDocumentationFile>true</GenerateDocumentationFile>
99
<PackageTags>aspnetcore;session;sessionstate</PackageTags>
1010
<IsPackable>false</IsPackable>
11-
<Nullable>enable</Nullable>
11+
<IsTrimmable>true</IsTrimmable>
1212
</PropertyGroup>
1313

1414
<ItemGroup>

src/Security/Authentication/Certificate/src/Microsoft.AspNetCore.Authentication.Certificate.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<DefineConstants>$(DefineConstants);SECURITY</DefineConstants>
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>
88
<PackageTags>aspnetcore;authentication;security;x509;certificate</PackageTags>
9-
<Nullable>enable</Nullable>
9+
<IsTrimmable>true</IsTrimmable>
1010
</PropertyGroup>
1111

1212
<ItemGroup>

src/Security/Authentication/Cookies/src/Microsoft.AspNetCore.Authentication.Cookies.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<GenerateDocumentationFile>true</GenerateDocumentationFile>
99
<PackageTags>aspnetcore;authentication;security</PackageTags>
1010
<IsPackable>false</IsPackable>
11-
<Nullable>enable</Nullable>
11+
<IsTrimmable>true</IsTrimmable>
1212
</PropertyGroup>
1313

1414
<ItemGroup>

src/Security/Authentication/Core/src/AuthenticationBuilder.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ public AuthenticationBuilder(IServiceCollection services)
2929
where TOptions : AuthenticationSchemeOptions, new()
3030
where THandler : class, IAuthenticationHandler
3131
{
32+
var state = new AddSchemeHelperState(typeof(THandler));
3233
Services.Configure<AuthenticationOptions>(o =>
3334
{
3435
o.AddScheme(authenticationScheme, scheme =>
3536
{
36-
scheme.HandlerType = typeof(THandler);
37+
scheme.HandlerType = state.HandlerType;
3738
scheme.DisplayName = displayName;
3839
});
3940
});
@@ -50,6 +51,18 @@ public AuthenticationBuilder(IServiceCollection services)
5051
return this;
5152
}
5253

54+
// Workaround for linker bug: https://github.com/dotnet/linker/issues/1981
55+
private readonly struct AddSchemeHelperState
56+
{
57+
public AddSchemeHelperState([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] Type handlerType)
58+
{
59+
HandlerType = handlerType;
60+
}
61+
62+
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)]
63+
public Type HandlerType { get; }
64+
}
65+
5366
/// <summary>
5467
/// Adds a <see cref="AuthenticationScheme"/> which can be used by <see cref="IAuthenticationService"/>.
5568
/// </summary>

src/Security/Authentication/Core/src/Microsoft.AspNetCore.Authentication.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>
88
<PackageTags>aspnetcore;authentication;security</PackageTags>
99
<IsPackable>false</IsPackable>
10-
<Nullable>enable</Nullable>
10+
<IsTrimmable>true</IsTrimmable>
1111
</PropertyGroup>
1212

1313
<ItemGroup>

src/Security/Authentication/Facebook/src/Microsoft.AspNetCore.Authentication.Facebook.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
66
<GenerateDocumentationFile>true</GenerateDocumentationFile>
77
<PackageTags>aspnetcore;authentication;security</PackageTags>
8-
<Nullable>enable</Nullable>
8+
<IsTrimmable>true</IsTrimmable>
99
</PropertyGroup>
1010

1111
<ItemGroup>

src/Security/Authentication/Google/src/Microsoft.AspNetCore.Authentication.Google.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
66
<GenerateDocumentationFile>true</GenerateDocumentationFile>
77
<PackageTags>aspnetcore;authentication;security</PackageTags>
8-
<Nullable>enable</Nullable>
8+
<IsTrimmable>true</IsTrimmable>
99
</PropertyGroup>
1010

1111
<ItemGroup>

src/Security/Authentication/JwtBearer/src/Microsoft.AspNetCore.Authentication.JwtBearer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>
66
<GenerateDocumentationFile>true</GenerateDocumentationFile>
77
<PackageTags>aspnetcore;authentication;security</PackageTags>
8-
<Nullable>enable</Nullable>
8+
<IsTrimmable>true</IsTrimmable>
99
</PropertyGroup>
1010

1111
<ItemGroup>

0 commit comments

Comments
 (0)