Merge branch 'release/2.2' -> 'master' (#9591)

This commit is contained in:
Doug Bunting 2019-04-22 11:12:35 -07:00 committed by GitHub
commit 1c19e8ee89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 58 additions and 35 deletions

View File

@ -43,7 +43,13 @@ Later on, this will be checked using this condition:
<PackagesInPatch>
Microsoft.AspNetCore.AspNetCoreModule;
Microsoft.AspNetCore.AspNetCoreModuleV2;
Microsoft.AspNetCore.Identity.UI;
java:signalr;
Microsoft.AspNetCore.Mvc.Core;
Microsoft.AspNetCore.Mvc.RazorPages;
Microsoft.AspNetCore.AzureAppServicesIntegration;
Microsoft.AspNetCore.AzureAppServices.HostingStartup;
Microsoft.AspNetCore.AzureAppServices.SiteExtension;
</PackagesInPatch>
</PropertyGroup>

View File

@ -31,6 +31,7 @@ namespace Microsoft.AspNetCore.Mvc
private static readonly double TimestampToTicks = TimeSpan.TicksPerSecond / (double)Stopwatch.Frequency;
private static readonly Action<ILogger, string, string, Exception> _actionExecuting;
private static readonly Action<ILogger, string, MethodInfo, string, string, Exception> _controllerActionExecuting;
private static readonly Action<ILogger, string, double, Exception> _actionExecuted;
private static readonly Action<ILogger, string, string, Exception> _pageExecuting;
@ -41,7 +42,7 @@ namespace Microsoft.AspNetCore.Mvc
private static readonly Action<ILogger, string, Exception> _contentResultExecuting;
private static readonly Action<ILogger, string, ModelValidationState, Exception> _actionMethodExecuting;
private static readonly Action<ILogger, string, string[], ModelValidationState, Exception> _actionMethodExecutingWithArguments;
private static readonly Action<ILogger, string, string[], Exception> _actionMethodExecutingWithArguments;
private static readonly Action<ILogger, string, string, double, Exception> _actionMethodExecuted;
private static readonly Action<ILogger, string, string[], Exception> _logFilterExecutionPlan;
@ -159,6 +160,11 @@ namespace Microsoft.AspNetCore.Mvc
new EventId(1, "ActionExecuting"),
"Route matched with {RouteData}. Executing action {ActionName}");
_controllerActionExecuting = LoggerMessage.Define<string, MethodInfo, string, string>(
LogLevel.Information,
new EventId(3, "ControllerActionExecuting"),
"Route matched with {RouteData}. Executing controller action with signature {MethodInfo} on controller {Controller} ({AssemblyName}).");
_actionExecuted = LoggerMessage.Define<string, double>(
LogLevel.Information,
new EventId(2, "ActionExecuted"),
@ -189,10 +195,10 @@ namespace Microsoft.AspNetCore.Mvc
new EventId(1, "ActionMethodExecuting"),
"Executing action method {ActionName} - Validation state: {ValidationState}");
_actionMethodExecutingWithArguments = LoggerMessage.Define<string, string[], ModelValidationState>(
LogLevel.Information,
_actionMethodExecutingWithArguments = LoggerMessage.Define<string, string[]>(
LogLevel.Trace,
new EventId(1, "ActionMethodExecutingWithArguments"),
"Executing action method {ActionName} with arguments ({Arguments}) - Validation state: {ValidationState}");
"Executing action method {ActionName} with arguments ({Arguments})");
_actionMethodExecuted = LoggerMessage.Define<string, string, double>(
LogLevel.Information,
@ -713,13 +719,29 @@ namespace Microsoft.AspNetCore.Mvc
stringBuilder.Append($"{routeKeys[i]} = \"{routeValues[i]}\", ");
}
}
if (action.RouteValues.TryGetValue("page", out var page) && page != null)
{
_pageExecuting(logger, stringBuilder.ToString(), action.DisplayName, null);
}
else
{
_actionExecuting(logger, stringBuilder.ToString(), action.DisplayName, null);
if (action is ControllerActionDescriptor controllerActionDescriptor)
{
var controllerType = controllerActionDescriptor.ControllerTypeInfo.AsType();
var controllerName = TypeNameHelper.GetTypeDisplayName(controllerType);
_controllerActionExecuting(
logger,
stringBuilder.ToString(),
controllerActionDescriptor.MethodInfo,
controllerName,
controllerType.Assembly.GetName().Name,
null);
}
else
{
_actionExecuting(logger, stringBuilder.ToString(), action.DisplayName, null);
}
}
}
}
@ -858,21 +880,17 @@ namespace Microsoft.AspNetCore.Mvc
var actionName = context.ActionDescriptor.DisplayName;
var validationState = context.ModelState.ValidationState;
_actionMethodExecuting(logger, actionName, validationState, null);
string[] convertedArguments;
if (arguments == null)
if (arguments != null && logger.IsEnabled(LogLevel.Trace))
{
_actionMethodExecuting(logger, actionName, validationState, null);
}
else
{
convertedArguments = new string[arguments.Length];
var convertedArguments = new string[arguments.Length];
for (var i = 0; i < arguments.Length; i++)
{
convertedArguments[i] = Convert.ToString(arguments[i]);
}
_actionMethodExecutingWithArguments(logger, actionName, convertedArguments, validationState, null);
_actionMethodExecutingWithArguments(logger, actionName, convertedArguments, null);
}
}
}

View File

@ -13,8 +13,9 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
{
public const string PageFilter = "Page Filter";
private static readonly Action<ILogger, string, string[], ModelValidationState, Exception> _handlerMethodExecuting;
private static readonly Action<ILogger, string, ModelValidationState, Exception> _handlerMethodExecuting;
private static readonly Action<ILogger, ModelValidationState, Exception> _implicitHandlerMethodExecuting;
private static readonly Action<ILogger, string, string[], Exception> _handlerMethodExecutingWithArguments;
private static readonly Action<ILogger, string, string, Exception> _handlerMethodExecuted;
private static readonly Action<ILogger, string, Exception> _implicitHandlerMethodExecuted;
private static readonly Action<ILogger, object, Exception> _pageFilterShortCircuit;
@ -26,10 +27,15 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
{
// These numbers start at 101 intentionally to avoid conflict with the IDs used by ResourceInvoker.
_handlerMethodExecuting = LoggerMessage.Define<string, string[], ModelValidationState>(
_handlerMethodExecuting = LoggerMessage.Define<string, ModelValidationState>(
LogLevel.Information,
new EventId(101, "ExecutingHandlerMethod"),
"Executing handler method {HandlerName} with arguments ({Arguments}) - ModelState is {ValidationState}");
"Executing handler method {HandlerName} - ModelState is {ValidationState}");
_handlerMethodExecutingWithArguments = LoggerMessage.Define<string, string[]>(
LogLevel.Trace,
new EventId(103, "HandlerMethodExecutingWithArguments"),
"Executing handler method {HandlerName} with arguments ({Arguments})");
_handlerMethodExecuted = LoggerMessage.Define<string, string>(
LogLevel.Information,
@ -73,23 +79,19 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
{
var handlerName = handler.MethodInfo.DeclaringType.FullName + "." + handler.MethodInfo.Name;
string[] convertedArguments;
if (arguments == null)
var validationState = context.ModelState.ValidationState;
_handlerMethodExecuting(logger, handlerName, validationState, null);
if (arguments != null && logger.IsEnabled(LogLevel.Trace))
{
convertedArguments = null;
}
else
{
convertedArguments = new string[arguments.Length];
var convertedArguments = new string[arguments.Length];
for (var i = 0; i < arguments.Length; i++)
{
convertedArguments[i] = Convert.ToString(arguments[i]);
}
_handlerMethodExecutingWithArguments(logger, handlerName, convertedArguments, null);
}
var validationState = context.ModelState.ValidationState;
_handlerMethodExecuting(logger, handlerName, convertedArguments, validationState, null);
}
}

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>netcoreapp3.0</TargetFrameworks>
<TargetFrameworks Condition="'$(BenchmarksTargetFramework)' != ''">$(BenchmarksTargetFramework)</TargetFrameworks>

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
@ -7,7 +7,6 @@
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Mvc" />
<Reference Include="Microsoft.AspNetCore.Server.IISIntegration" />
<Reference Include="Microsoft.AspNetCore.Server.Kestrel" />
<Reference Include="Microsoft.AspNetCore.StaticFiles" />

View File

@ -19,7 +19,6 @@
<Reference Include="Microsoft.AspNetCore.Server.Kestrel" />
<Reference Include="Microsoft.AspNetCore.StaticFiles" />
<Reference Include="Microsoft.AspNetCore.Diagnostics" />
</ItemGroup>
</Project>

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
@ -8,7 +8,6 @@
<ItemGroup>
<Reference Include="Microsoft.AspNetCore.Mvc" />
<Reference Include="Microsoft.AspNetCore.Server.IISIntegration" />
<Reference Include="Microsoft.AspNetCore.Server.Kestrel" />
<Reference Include="Microsoft.AspNetCore.StaticFiles" />