Skip to content

[automated] Merge branch 'release/5.0' => 'master' #25219

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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
f2c3c11
Minor typos (#25140)
ar0311 Aug 24, 2020
db77380
Java client connection state part 1 (#24166)
BrennanConroy Aug 24, 2020
29cbf6e
Make PropertySetter a concrete type (#25054)
pranavkm Aug 25, 2020
0050ece
[release/5.0] Update dependencies from dotnet/runtime dotnet/efcore (…
dotnet-maestro[bot] Aug 25, 2020
8a2f29b
JSObjectReference (#25028)
MackinnonBuck Aug 25, 2020
aa1646b
Update dependencies from https://github.com/dotnet/runtime build 2020…
dotnet-maestro[bot] Aug 25, 2020
e409c97
Allow suppressing the use of environment variables (#25136)
Tratcher Aug 25, 2020
a01f9eb
[release/5.0] Update dependencies from dotnet/efcore dotnet/runtime (…
dotnet-maestro[bot] Aug 25, 2020
0ff360d
[release/5.0] Update dependencies from dotnet/efcore (#25237)
dotnet-maestro[bot] Aug 25, 2020
3f81caa
[release/5.0] Update dependencies from dotnet/runtime dotnet/efcore (…
dotnet-maestro[bot] Aug 25, 2020
6333040
Fix MaxRequestBodySize in IIS (#25096)
jkotalik Aug 25, 2020
64c47b7
Support custom validation class names (#24835)
SteveSandersonMS Aug 25, 2020
a9b596e
Prevent @import in scoped CSS (#25196)
SteveSandersonMS Aug 25, 2020
78a587b
Guard against client disconnect exceptions that appear when reading b…
pranavkm Aug 25, 2020
402dc41
[Blazor] Render Blazor Webassembly components from MVC (#25203)
javiercn Aug 25, 2020
70ea49f
Update dependencies from https://github.com/dotnet/efcore build 20200…
dotnet-maestro[bot] Aug 25, 2020
b0530a6
Do not include the shared framework in the packages (#24816)
pranavkm Aug 25, 2020
c2f0331
Include project file in F# Worker Service template (#25180)
dougbu Aug 25, 2020
098be5f
Use LDAP support from DirectoryServices.Protocols for RBAC claim reso…
Aug 25, 2020
e2dd296
Set SameSiteMode for cookies in authentication tests (#25281)
captainsafia Aug 26, 2020
2916f4b
Fixed server interop reliability tests (#25244)
MackinnonBuck Aug 26, 2020
f2b72b0
Fix SignalR typescript tests with Chrome SameSite reaction (#25283)
BrennanConroy Aug 26, 2020
826b5ba
Merge branch 'release/5.0'
ajaybhargavb Aug 26, 2020
bb769fe
[release/5.0] Reduce job timeouts in aspnetcore-quarantined-pr pipeli…
dougbu Aug 27, 2020
7b8fe53
Disable failing/hanging tests due to Chrome/Selenium issue (#25323)
Aug 27, 2020
e9a564d
[master] Reduce job timeouts in aspnetcore-quarantined-pr pipeline (#…
dougbu Aug 27, 2020
78271cf
Disable failing/hanging tests due to Chrome/Selenium issue (#25323)
Aug 27, 2020
81ed8a4
Merge branch 'release/5.0' into merge/release/5.0-to-master
Aug 27, 2020
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
8 changes: 4 additions & 4 deletions .azure/pipelines/quarantined-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
jobName: Helix_quarantined_x64
jobDisplayName: 'Tests: Helix'
agentOs: Windows
timeoutInMinutes: 240
timeoutInMinutes: 120
steps:
# Build the shared framework
- script: ./build.cmd -ci -nobl -all -pack -arch x64 /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log
Expand All @@ -53,7 +53,7 @@ jobs:
jobName: Windows_Quarantined_x64
jobDisplayName: 'Tests: Windows x64'
agentOs: Windows
timeoutInMinutes: 240
timeoutInMinutes: 90
isTestingJob: true
steps:
- powershell: "& ./build.ps1 -CI -nobl -all -pack -NoBuildJava"
Expand Down Expand Up @@ -86,7 +86,7 @@ jobs:
jobName: MacOS_Quarantined_Test
jobDisplayName: "Tests: macOS 10.14"
agentOs: macOS
timeoutInMinutes: 240
timeoutInMinutes: 60
isTestingJob: true
steps:
- bash: ./build.sh --all --pack --ci --nobl --no-build-java
Expand Down Expand Up @@ -119,7 +119,7 @@ jobs:
jobName: Linux_Quarantined_Test
jobDisplayName: "Tests: Ubuntu 16.04 x64"
agentOs: Linux
timeoutInMinutes: 240
timeoutInMinutes: 60
isTestingJob: true
useHostedUbuntu: false
steps:
Expand Down
15 changes: 15 additions & 0 deletions AspNetCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -1507,6 +1507,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Diagno
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Extensions.Diagnostics.HealthChecks.Tests", "src\HealthChecks\HealthChecks\test\Microsoft.Extensions.Diagnostics.HealthChecks.Tests.csproj", "{7509AA1E-3093-4BEE-984F-E11579E98A11}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.JSInterop.Tests", "src\JSInterop\Microsoft.JSInterop\test\Microsoft.JSInterop.Tests.csproj", "{DAAB6B35-CBD2-4573-B633-CDD42F583A0E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -7179,6 +7181,18 @@ Global
{7509AA1E-3093-4BEE-984F-E11579E98A11}.Release|x64.Build.0 = Release|Any CPU
{7509AA1E-3093-4BEE-984F-E11579E98A11}.Release|x86.ActiveCfg = Release|Any CPU
{7509AA1E-3093-4BEE-984F-E11579E98A11}.Release|x86.Build.0 = Release|Any CPU
{DAAB6B35-CBD2-4573-B633-CDD42F583A0E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DAAB6B35-CBD2-4573-B633-CDD42F583A0E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DAAB6B35-CBD2-4573-B633-CDD42F583A0E}.Debug|x64.ActiveCfg = Debug|Any CPU
{DAAB6B35-CBD2-4573-B633-CDD42F583A0E}.Debug|x64.Build.0 = Debug|Any CPU
{DAAB6B35-CBD2-4573-B633-CDD42F583A0E}.Debug|x86.ActiveCfg = Debug|Any CPU
{DAAB6B35-CBD2-4573-B633-CDD42F583A0E}.Debug|x86.Build.0 = Debug|Any CPU
{DAAB6B35-CBD2-4573-B633-CDD42F583A0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DAAB6B35-CBD2-4573-B633-CDD42F583A0E}.Release|Any CPU.Build.0 = Release|Any CPU
{DAAB6B35-CBD2-4573-B633-CDD42F583A0E}.Release|x64.ActiveCfg = Release|Any CPU
{DAAB6B35-CBD2-4573-B633-CDD42F583A0E}.Release|x64.Build.0 = Release|Any CPU
{DAAB6B35-CBD2-4573-B633-CDD42F583A0E}.Release|x86.ActiveCfg = Release|Any CPU
{DAAB6B35-CBD2-4573-B633-CDD42F583A0E}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -7934,6 +7948,7 @@ Global
{B06040BC-DA28-4923-8CAC-20EB517D471B} = {22D7D74B-565D-4047-97B4-F149B1A13350}
{55CACC1F-FE96-47C8-8073-91F4CAA55C75} = {2A91479A-4ABE-4BB7-9A5E-CA3B9CCFC69E}
{7509AA1E-3093-4BEE-984F-E11579E98A11} = {7CB09412-C9B0-47E8-A8C3-311AA4CFDE04}
{DAAB6B35-CBD2-4573-B633-CDD42F583A0E} = {16898702-3E33-41C1-B8D8-4CE3F1D46BD9}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3E8720B3-DBDD-498C-B383-2CC32A054E8F}
Expand Down
1 change: 1 addition & 0 deletions eng/Dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ and are generated based on the last package release.
<LatestPackageReference Include="System.ComponentModel.Annotations" />
<LatestPackageReference Include="System.Diagnostics.DiagnosticSource" />
<LatestPackageReference Include="System.Diagnostics.EventLog" />
<LatestPackageReference Include="System.DirectoryServices.Protocols" />
<LatestPackageReference Include="System.Drawing.Common" />
<LatestPackageReference Include="System.IO.Pipelines" />
<LatestPackageReference Include="System.Net.Http" />
Expand Down
4 changes: 4 additions & 0 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>907f7da59b40c80941b02ac2a46650adf3f606bc</Sha>
</Dependency>
<Dependency Name="System.DirectoryServices.Protocols" Version="5.0.0-rc.1.20417.14">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>907f7da59b40c80941b02ac2a46650adf3f606bc</Sha>
</Dependency>
<Dependency Name="System.Drawing.Common" Version="5.0.0-rc.1.20417.14">
<Uri>https://github.com/dotnet/runtime</Uri>
<Sha>907f7da59b40c80941b02ac2a46650adf3f606bc</Sha>
Expand Down
1 change: 1 addition & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
<SystemComponentModelAnnotationsPackageVersion>5.0.0-rc.1.20417.14</SystemComponentModelAnnotationsPackageVersion>
<SystemDiagnosticsDiagnosticSourcePackageVersion>5.0.0-rc.1.20417.14</SystemDiagnosticsDiagnosticSourcePackageVersion>
<SystemDiagnosticsEventLogPackageVersion>5.0.0-rc.1.20417.14</SystemDiagnosticsEventLogPackageVersion>
<SystemDirectoryServicesProtocolsPackageVersion>5.0.0-rc.1.20417.14</SystemDirectoryServicesProtocolsPackageVersion>
<SystemDrawingCommonPackageVersion>5.0.0-rc.1.20417.14</SystemDrawingCommonPackageVersion>
<SystemIOPipelinesPackageVersion>5.0.0-rc.1.20417.14</SystemIOPipelinesPackageVersion>
<SystemNetHttpJsonPackageVersion>5.0.0-rc.1.20417.14</SystemNetHttpJsonPackageVersion>
Expand Down
20 changes: 19 additions & 1 deletion src/Antiforgery/src/Internal/DefaultAntiforgeryTokenStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Diagnostics;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
Expand Down Expand Up @@ -57,7 +58,24 @@ public async Task<AntiforgeryTokenSet> GetRequestTokensAsync(HttpContext httpCon
{
// Check the content-type before accessing the form collection to make sure
// we report errors gracefully.
var form = await httpContext.Request.ReadFormAsync();
IFormCollection form;
try
{
form = await httpContext.Request.ReadFormAsync();
}
catch (InvalidDataException ex)
{
// ReadFormAsync can throw InvalidDataException if the form content is malformed.
// Wrap it in an AntiforgeryValidationException and allow the caller to handle it as just another antiforgery failure.
throw new AntiforgeryValidationException(Resources.AntiforgeryToken_UnableToReadRequest, ex);
}
catch (IOException ex)
{
// Reading the request body (which happens as part of ReadFromAsync) may throw an exception if a client disconnects.
// Wrap it in an AntiforgeryValidationException and allow the caller to handle it as just another antiforgery failure.
throw new AntiforgeryValidationException(Resources.AntiforgeryToken_UnableToReadRequest, ex);
}

requestToken = form[_options.FormFieldName];
}

Expand Down
3 changes: 3 additions & 0 deletions src/Antiforgery/src/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@
<data name="AntiforgeryToken_TokensSwapped" xml:space="preserve">
<value>Validation of the provided antiforgery token failed. The cookie token and the request token were swapped.</value>
</data>
<data name="AntiforgeryToken_UnableToReadRequest" xml:space="preserve">
<value>Unable to read the antiforgery request token from the posted form.</value>
</data>
<data name="AntiforgeryToken_UsernameMismatch" xml:space="preserve">
<value>The provided antiforgery token was meant for user "{0}", but the current user is "{1}".</value>
</data>
Expand Down
52 changes: 52 additions & 0 deletions src/Antiforgery/test/DefaultAntiforgeryTokenStoreTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Primitives;
Expand Down Expand Up @@ -235,6 +237,56 @@ public async Task GetRequestTokens_BothHeaderValueAndFormFieldsEmpty_ReturnsNull
Assert.Null(tokenSet.RequestToken);
}

[Fact]
public async Task GetRequestTokens_ReadFormAsyncThrowsIOException_ThrowsAntiforgeryValidationException()
{
// Arrange
var ioException = new IOException();
var httpContext = new Mock<HttpContext>();

httpContext.Setup(r => r.Request.Cookies).Returns(Mock.Of<IRequestCookieCollection>());
httpContext.SetupGet(r => r.Request.HasFormContentType).Returns(true);
httpContext.Setup(r => r.Request.ReadFormAsync(It.IsAny<CancellationToken>())).Throws(ioException);

var options = new AntiforgeryOptions
{
Cookie = { Name = "cookie-name" },
FormFieldName = "form-field-name",
HeaderName = null,
};

var tokenStore = new DefaultAntiforgeryTokenStore(new TestOptionsManager(options));

// Act & Assert
var ex = await Assert.ThrowsAsync<AntiforgeryValidationException>(() => tokenStore.GetRequestTokensAsync(httpContext.Object));
Assert.Same(ioException, ex.InnerException);
}

[Fact]
public async Task GetRequestTokens_ReadFormAsyncThrowsInvalidDataException_ThrowsAntiforgeryValidationException()
{
// Arrange
var exception = new InvalidDataException();
var httpContext = new Mock<HttpContext>();

httpContext.Setup(r => r.Request.Cookies).Returns(Mock.Of<IRequestCookieCollection>());
httpContext.SetupGet(r => r.Request.HasFormContentType).Returns(true);
httpContext.Setup(r => r.Request.ReadFormAsync(It.IsAny<CancellationToken>())).Throws(exception);

var options = new AntiforgeryOptions
{
Cookie = { Name = "cookie-name" },
FormFieldName = "form-field-name",
HeaderName = null,
};

var tokenStore = new DefaultAntiforgeryTokenStore(new TestOptionsManager(options));

// Act & Assert
var ex = await Assert.ThrowsAsync<AntiforgeryValidationException>(() => tokenStore.GetRequestTokensAsync(httpContext.Object));
Assert.Same(exception, ex.InnerException);
}

[Theory]
[InlineData(false, CookieSecurePolicy.SameAsRequest, null)]
[InlineData(true, CookieSecurePolicy.SameAsRequest, true)]
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Components/src/ComponentFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private Action<IServiceProvider, IComponent> CreateInitializer(Type type)
(
propertyName: property.Name,
propertyType: property.PropertyType,
setter: MemberAssignment.CreatePropertySetter(type, property, cascading: false)
setter: new PropertySetter(type, property)
)).ToArray();

return Initialize;
Expand Down
21 changes: 12 additions & 9 deletions src/Components/Components/src/Reflection/ComponentProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public static void SetProperties(in ParameterView parameters, object target)
}
}

static void SetProperty(object target, IPropertySetter writer, string parameterName, object value)
static void SetProperty(object target, PropertySetter writer, string parameterName, object value)
{
try
{
Expand Down Expand Up @@ -246,13 +246,13 @@ private static void ThrowForInvalidCaptureUnmatchedValuesParameterType(Type targ
private class WritersForType
{
private const int MaxCachedWriterLookups = 100;
private readonly Dictionary<string, IPropertySetter> _underlyingWriters;
private readonly ConcurrentDictionary<string, IPropertySetter?> _referenceEqualityWritersCache;
private readonly Dictionary<string, PropertySetter> _underlyingWriters;
private readonly ConcurrentDictionary<string, PropertySetter?> _referenceEqualityWritersCache;

public WritersForType(Type targetType)
{
_underlyingWriters = new Dictionary<string, IPropertySetter>(StringComparer.OrdinalIgnoreCase);
_referenceEqualityWritersCache = new ConcurrentDictionary<string, IPropertySetter?>(ReferenceEqualityComparer.Instance);
_underlyingWriters = new Dictionary<string, PropertySetter>(StringComparer.OrdinalIgnoreCase);
_referenceEqualityWritersCache = new ConcurrentDictionary<string, PropertySetter?>(ReferenceEqualityComparer.Instance);

foreach (var propertyInfo in GetCandidateBindableProperties(targetType))
{
Expand All @@ -271,7 +271,10 @@ public WritersForType(Type targetType)
$"The type '{targetType.FullName}' declares a parameter matching the name '{propertyName}' that is not public. Parameters must be public.");
}

var propertySetter = MemberAssignment.CreatePropertySetter(targetType, propertyInfo, cascading: cascadingParameterAttribute != null);
var propertySetter = new PropertySetter(targetType, propertyInfo)
{
Cascading = cascadingParameterAttribute != null,
};

if (_underlyingWriters.ContainsKey(propertyName))
{
Expand All @@ -298,17 +301,17 @@ public WritersForType(Type targetType)
ThrowForInvalidCaptureUnmatchedValuesParameterType(targetType, propertyInfo);
}

CaptureUnmatchedValuesWriter = MemberAssignment.CreatePropertySetter(targetType, propertyInfo, cascading: false);
CaptureUnmatchedValuesWriter = new PropertySetter(targetType, propertyInfo);
CaptureUnmatchedValuesPropertyName = propertyInfo.Name;
}
}
}

public IPropertySetter? CaptureUnmatchedValuesWriter { get; }
public PropertySetter? CaptureUnmatchedValuesWriter { get; }

public string? CaptureUnmatchedValuesPropertyName { get; }

public bool TryGetValue(string parameterName, [MaybeNullWhen(false)] out IPropertySetter writer)
public bool TryGetValue(string parameterName, [MaybeNullWhen(false)] out PropertySetter writer)
{
// In intensive parameter-passing scenarios, one of the most expensive things we do is the
// lookup from parameterName to writer. Pre-5.0 that was because of the string hashing.
Expand Down
49 changes: 46 additions & 3 deletions src/Components/Components/src/Reflection/IPropertySetter.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,55 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Reflection;

namespace Microsoft.AspNetCore.Components.Reflection
{
internal interface IPropertySetter
internal sealed class PropertySetter
{
bool Cascading { get; }
private static readonly MethodInfo CallPropertySetterOpenGenericMethod =
typeof(PropertySetter).GetMethod(nameof(CallPropertySetter), BindingFlags.NonPublic | BindingFlags.Static)!;

private readonly Action<object, object> _setterDelegate;

public PropertySetter(Type targetType, PropertyInfo property)
{
if (property.SetMethod == null)
{
throw new InvalidOperationException($"Cannot provide a value for property " +
$"'{property.Name}' on type '{targetType.FullName}' because the property " +
$"has no setter.");
}

var setMethod = property.SetMethod;

var propertySetterAsAction =
setMethod.CreateDelegate(typeof(Action<,>).MakeGenericType(targetType, property.PropertyType));
var callPropertySetterClosedGenericMethod =
CallPropertySetterOpenGenericMethod.MakeGenericMethod(targetType, property.PropertyType);
_setterDelegate = (Action<object, object>)
callPropertySetterClosedGenericMethod.CreateDelegate(typeof(Action<object, object>), propertySetterAsAction);
}

public bool Cascading { get; init; }

public void SetValue(object target, object value) => _setterDelegate(target, value);

void SetValue(object target, object value);
private static void CallPropertySetter<TTarget, TValue>(
Action<TTarget, TValue> setter,
object target,
object value)
where TTarget : notnull
{
if (value == null)
{
setter((TTarget)target, default!);
}
else
{
setter((TTarget)target, (TValue)value);
}
}
}
}
41 changes: 0 additions & 41 deletions src/Components/Components/src/Reflection/MemberAssignment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,46 +44,5 @@ public static IEnumerable<PropertyInfo> GetPropertiesIncludingInherited(

return dictionary.Values.SelectMany(p => p);
}

public static IPropertySetter CreatePropertySetter(Type targetType, PropertyInfo property, bool cascading)
{
if (property.SetMethod == null)
{
throw new InvalidOperationException($"Cannot provide a value for property " +
$"'{property.Name}' on type '{targetType.FullName}' because the property " +
$"has no setter.");
}

return (IPropertySetter)Activator.CreateInstance(
typeof(PropertySetter<,>).MakeGenericType(targetType, property.PropertyType),
property.SetMethod,
cascading)!;
}

class PropertySetter<TTarget, TValue> : IPropertySetter where TTarget : notnull
{
private readonly Action<TTarget, TValue> _setterDelegate;

public PropertySetter(MethodInfo setMethod, bool cascading)
{
_setterDelegate = (Action<TTarget, TValue>)Delegate.CreateDelegate(
typeof(Action<TTarget, TValue>), setMethod);
Cascading = cascading;
}

public bool Cascading { get; }

public void SetValue(object target, object value)
{
if (value == null)
{
_setterDelegate((TTarget)target, default!);
}
else
{
_setterDelegate((TTarget)target, (TValue)value);
}
}
}
}
}
Loading