Skip to content

Commit f490dd2

Browse files
Merge pull request #25039 from dotnet-maestro-bot/merge/release/5.0-to-master
[automated] Merge branch 'release/5.0' => 'master'
2 parents aa82818 + e5bf53e commit f490dd2

File tree

58 files changed

+600
-112
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+600
-112
lines changed

src/Components/WebAssembly/Sdk/integrationtests/WasmPublishIntegrationTest.cs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,8 +141,6 @@ public async Task Publish_WithScopedCss_Works()
141141
serviceWorkerPath: Path.Combine("serviceworkers", "my-service-worker.js"),
142142
serviceWorkerContent: "// This is the production service worker",
143143
assetsManifestPath: "custom-service-worker-assets.js");
144-
145-
VerifyTypeGranularTrimming(result, blazorPublishDirectory);
146144
}
147145

148146
[Fact]
@@ -906,16 +904,17 @@ static string ParseWebFormattedHash(string webFormattedHash)
906904

907905
private void VerifyTypeGranularTrimming(MSBuildResult result, string blazorPublishDirectory)
908906
{
909-
var loggingAssemblyPath = Path.Combine(blazorPublishDirectory, "_framework", "Microsoft.Extensions.Logging.Abstractions.dll");
910-
Assert.FileExists(result, loggingAssemblyPath);
907+
var componentsShimAssemblyPath = Path.Combine(blazorPublishDirectory, "_framework", "Microsoft.AspNetCore.Razor.Test.ComponentShim.dll");
908+
Assert.FileExists(result, componentsShimAssemblyPath);
909+
910+
// RouteView is referenced by the app, so we expect it to be preserved
911+
Assert.AssemblyContainsType(result, componentsShimAssemblyPath, "Microsoft.AspNetCore.Components.RouteView");
911912

912-
// ILogger is referenced by the app, so we expect it to be preserved
913-
Assert.AssemblyContainsType(result, loggingAssemblyPath, "Microsoft.Extensions.Logging.ILogger");
914-
// LogLevel is referenced by ILogger and therefore must be preserved.
915-
Assert.AssemblyContainsType(result, loggingAssemblyPath, "Microsoft.Extensions.Logging.LogLevel");
913+
// RouteData is referenced by RouteView so we expect it to be preserved.
914+
Assert.AssemblyContainsType(result, componentsShimAssemblyPath, "Microsoft.AspNetCore.Components.RouteData");
916915

917-
// NullLogger is not referenced by the app, and should be trimmed.
918-
Assert.AssemblyDoesNotContainType(result, loggingAssemblyPath, "Microsoft.Extensions.Logging.Abstractions.NullLogger");
916+
// CascadingParameterAttribute is not referenced by the app, and should be trimmed.
917+
Assert.AssemblyDoesNotContainType(result, componentsShimAssemblyPath, "Microsoft.AspNetCore.Components.CascadingParameterAttribute");
919918
}
920919

921920
private static BootJsonData ReadBootJsonData(MSBuildResult result, string path)

src/Components/WebAssembly/Sdk/src/targets/Microsoft.NET.Sdk.BlazorWebAssembly.Current.targets

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ Copyright (c) .NET Foundation. All rights reserved.
6969

7070
</PropertyGroup>
7171

72+
<ItemGroup>
73+
<!-- Configuration for the platform compatibility analyzer. See https://github.com/dotnet/designs/blob/master/accepted/2020/platform-exclusion/platform-exclusion.md#build-configuration-for-platforms -->
74+
<SupportedPlatform Remove="@(SupportedPlatform)" />
75+
<SupportedPlatform Include="browser" />
76+
</ItemGroup>
77+
7278
<Import Project="Microsoft.NET.Sdk.BlazorWebAssembly.ServiceWorkerAssetsManifest.targets" Condition="'$(ServiceWorkerAssetsManifest)' != ''" />
7379

7480
<Target Name="_ScrambleDotnetJsFileName" AfterTargets="ResolveRuntimePackAssets">
@@ -395,7 +401,7 @@ Copyright (c) .NET Foundation. All rights reserved.
395401
<ItemGroup>
396402
<_BlazorTypeGranularAssembly
397403
Include="@(ManagedAssemblyToLink)"
398-
Condition="'%(Extension)' == '.dll' AND ($([System.String]::Copy('%(Filename)').StartsWith('Microsoft.AspNetCore.')) or $([System.String]::Copy('%(Filename)').StartsWith('Microsoft.Extensions.')))">
404+
Condition="'%(Extension)' == '.dll' AND $([System.String]::Copy('%(Filename)').StartsWith('Microsoft.AspNetCore.'))">
399405
<Required>false</Required>
400406
<Preserve>all</Preserve>
401407
</_BlazorTypeGranularAssembly>

src/Components/WebAssembly/Sdk/testassets/blazorwasm/Program.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ public static void Main(string[] args)
88
{
99
GC.KeepAlive(typeof(System.Text.Json.JsonSerializer));
1010
GC.KeepAlive(typeof(RazorClassLibrary.Class1));
11-
GC.KeepAlive(typeof(Microsoft.Extensions.Logging.ILogger));
1211
#if REFERENCE_classlibrarywithsatelliteassemblies
1312
GC.KeepAlive(typeof(classlibrarywithsatelliteassemblies.Class1));
1413
#endif

src/FileProviders/Embedded/src/Manifest/ManifestDirectory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ internal static void ValidateChildrenAndSetParent(ManifestEntry[] children, Mani
9898

9999
private ManifestEntry[] CopyChildren()
100100
{
101-
var list = new List<ManifestEntry>();
101+
var list = new List<ManifestEntry>(Children.Count);
102102
for (int i = 0; i < Children.Count; i++)
103103
{
104104
var child = Children[i];

src/Http/Http/src/Features/RequestCookiesFeature.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public IRequestCookieCollection Cookies
8080
}
8181
else
8282
{
83-
var headers = new List<string>();
83+
var headers = new List<string>(_parsedValues.Count);
8484
foreach (var pair in _parsedValues)
8585
{
8686
headers.Add(new CookieHeaderValue(pair.Key, pair.Value).ToString());

src/Http/Routing/src/Patterns/RoutePatternFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ RoutePatternPart VisitPart(RoutePatternPart part)
497497
updatedParameterPolicies = new Dictionary<string, List<RoutePatternParameterPolicyReference>>(StringComparer.OrdinalIgnoreCase);
498498
}
499499

500-
parameterConstraints = new List<RoutePatternParameterPolicyReference>();
500+
parameterConstraints = new List<RoutePatternParameterPolicyReference>(parameter.ParameterPolicies.Count);
501501
updatedParameterPolicies.Add(parameter.Name, parameterConstraints);
502502
}
503503

src/Identity/Core/src/SignInManager.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,22 @@ public virtual async Task<bool> CanSignInAsync(TUser user)
169169
public virtual async Task RefreshSignInAsync(TUser user)
170170
{
171171
var auth = await Context.AuthenticateAsync(IdentityConstants.ApplicationScheme);
172-
var claims = new List<Claim>();
172+
IList<Claim> claims = Array.Empty<Claim>();
173+
173174
var authenticationMethod = auth?.Principal?.FindFirst(ClaimTypes.AuthenticationMethod);
174-
if (authenticationMethod != null)
175-
{
176-
claims.Add(authenticationMethod);
177-
}
178175
var amr = auth?.Principal?.FindFirst("amr");
179-
if (amr != null)
176+
177+
if (authenticationMethod != null || amr != null)
180178
{
181-
claims.Add(amr);
179+
claims = new List<Claim>();
180+
if (authenticationMethod != null)
181+
{
182+
claims.Add(authenticationMethod);
183+
}
184+
if (amr != null)
185+
{
186+
claims.Add(amr);
187+
}
182188
}
183189

184190
await SignInWithClaimsAsync(user, auth?.Properties, claims);
@@ -203,9 +209,10 @@ public virtual Task SignInAsync(TUser user, bool isPersistent, string authentica
203209
/// <returns>The task object representing the asynchronous operation.</returns>
204210
public virtual Task SignInAsync(TUser user, AuthenticationProperties authenticationProperties, string authenticationMethod = null)
205211
{
206-
var additionalClaims = new List<Claim>();
212+
IList<Claim> additionalClaims = Array.Empty<Claim>();
207213
if (authenticationMethod != null)
208214
{
215+
additionalClaims = new List<Claim>();
209216
additionalClaims.Add(new Claim(ClaimTypes.AuthenticationMethod, authenticationMethod));
210217
}
211218
return SignInWithClaimsAsync(user, authenticationProperties, additionalClaims);

src/Middleware/Localization/src/RequestLocalizationOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public RequestCulture DefaultRequestCulture
122122
/// <returns>The <see cref="RequestLocalizationOptions"/>.</returns>
123123
public RequestLocalizationOptions AddSupportedCultures(params string[] cultures)
124124
{
125-
var supportedCultures = new List<CultureInfo>();
125+
var supportedCultures = new List<CultureInfo>(cultures.Length);
126126

127127
foreach (var culture in cultures)
128128
{
@@ -140,7 +140,7 @@ public RequestLocalizationOptions AddSupportedCultures(params string[] cultures)
140140
/// <returns>The <see cref="RequestLocalizationOptions"/>.</returns>
141141
public RequestLocalizationOptions AddSupportedUICultures(params string[] uiCultures)
142142
{
143-
var supportedUICultures = new List<CultureInfo>();
143+
var supportedUICultures = new List<CultureInfo>(uiCultures.Length);
144144
foreach (var culture in uiCultures)
145145
{
146146
supportedUICultures.Add(new CultureInfo(culture));

src/Mvc/Mvc.Core/src/ApplicationModels/ApplicationModelFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ private static string CreateMixedRoutedActionDescriptorsErrorMessage(
309309
// Text to show as the attribute route template for conventionally routed actions.
310310
var nullTemplate = Resources.AttributeRoute_NullTemplateRepresentation;
311311

312-
var actionDescriptions = new List<string>();
312+
var actionDescriptions = new List<string>(actions.Count);
313313
for (var i = 0; i < actions.Count; i++)
314314
{
315315
var (action, selector) = actions[i];

src/Mvc/Mvc.Core/src/ApplicationModels/ControllerActionDescriptorBuilder.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private static void AddControllerPropertyDescriptors(ActionDescriptor actionDesc
6363

6464
private static void AddParameterDescriptors(ActionDescriptor actionDescriptor, ActionModel action)
6565
{
66-
var parameterDescriptors = new List<ParameterDescriptor>();
66+
var parameterDescriptors = new List<ParameterDescriptor>(action.Parameters.Count);
6767
foreach (var parameter in action.Parameters)
6868
{
6969
var parameterDescriptor = CreateParameterDescriptor(parameter);

0 commit comments

Comments
 (0)