MVC use concrete types for DiagnosticListener (#11730)

* MVC use concrete types for DiagnosticListener

* Use DiagnosticListener not DiagnosticSource

* Implement interface explicitly

* Code check

* Feedback

* Feedback

* IReadOnlyDictionary

* Remove InstrumentationContext

* DiagnosticSource in RazorPageActivator

* Code check

* Feedback
This commit is contained in:
Ben Adams 2019-07-15 21:38:46 +02:00 committed by Ryan Nowak
parent 8b9503ee9e
commit 09722d1ce5
24 changed files with 2435 additions and 776 deletions

View File

@ -88,13 +88,13 @@ namespace Microsoft.AspNetCore.Hosting.Tests
public void ActivityStopDoesNotFireIfNoListenerAttachedForStart() public void ActivityStopDoesNotFireIfNoListenerAttachedForStart()
{ {
// Arrange // Arrange
var diagnosticSource = new DiagnosticListener("DummySource"); var diagnosticListener = new DiagnosticListener("DummySource");
var logger = new LoggerWithScopes(isEnabled: true); var logger = new LoggerWithScopes(isEnabled: true);
var hostingApplication = CreateApplication(out var features, diagnosticSource: diagnosticSource, logger: logger); var hostingApplication = CreateApplication(out var features, diagnosticListener: diagnosticListener, logger: logger);
var startFired = false; var startFired = false;
var stopFired = false; var stopFired = false;
diagnosticSource.Subscribe(new CallbackDiagnosticListener(pair => diagnosticListener.Subscribe(new CallbackDiagnosticListener(pair =>
{ {
// This should not fire // This should not fire
if (pair.Key == "Microsoft.AspNetCore.Hosting.HttpRequestIn.Start") if (pair.Key == "Microsoft.AspNetCore.Hosting.HttpRequestIn.Start")
@ -128,14 +128,14 @@ namespace Microsoft.AspNetCore.Hosting.Tests
[Fact] [Fact]
public void ActivityIsNotCreatedWhenIsEnabledForActivityIsFalse() public void ActivityIsNotCreatedWhenIsEnabledForActivityIsFalse()
{ {
var diagnosticSource = new DiagnosticListener("DummySource"); var diagnosticListener = new DiagnosticListener("DummySource");
var hostingApplication = CreateApplication(out var features, diagnosticSource: diagnosticSource); var hostingApplication = CreateApplication(out var features, diagnosticListener: diagnosticListener);
bool eventsFired = false; bool eventsFired = false;
bool isEnabledActivityFired = false; bool isEnabledActivityFired = false;
bool isEnabledStartFired = false; bool isEnabledStartFired = false;
diagnosticSource.Subscribe(new CallbackDiagnosticListener(pair => diagnosticListener.Subscribe(new CallbackDiagnosticListener(pair =>
{ {
eventsFired |= pair.Key.StartsWith("Microsoft.AspNetCore.Hosting.HttpRequestIn"); eventsFired |= pair.Key.StartsWith("Microsoft.AspNetCore.Hosting.HttpRequestIn");
}), (s, o, arg3) => }), (s, o, arg3) =>
@ -162,14 +162,14 @@ namespace Microsoft.AspNetCore.Hosting.Tests
[Fact] [Fact]
public void ActivityIsCreatedButNotLoggedWhenIsEnabledForActivityStartIsFalse() public void ActivityIsCreatedButNotLoggedWhenIsEnabledForActivityStartIsFalse()
{ {
var diagnosticSource = new DiagnosticListener("DummySource"); var diagnosticListener = new DiagnosticListener("DummySource");
var hostingApplication = CreateApplication(out var features, diagnosticSource: diagnosticSource); var hostingApplication = CreateApplication(out var features, diagnosticListener: diagnosticListener);
bool eventsFired = false; bool eventsFired = false;
bool isEnabledStartFired = false; bool isEnabledStartFired = false;
bool isEnabledActivityFired = false; bool isEnabledActivityFired = false;
diagnosticSource.Subscribe(new CallbackDiagnosticListener(pair => diagnosticListener.Subscribe(new CallbackDiagnosticListener(pair =>
{ {
eventsFired |= pair.Key.StartsWith("Microsoft.AspNetCore.Hosting.HttpRequestIn"); eventsFired |= pair.Key.StartsWith("Microsoft.AspNetCore.Hosting.HttpRequestIn");
}), (s, o, arg3) => }), (s, o, arg3) =>
@ -199,12 +199,12 @@ namespace Microsoft.AspNetCore.Hosting.Tests
[Fact] [Fact]
public void ActivityIsCreatedAndLogged() public void ActivityIsCreatedAndLogged()
{ {
var diagnosticSource = new DiagnosticListener("DummySource"); var diagnosticListener = new DiagnosticListener("DummySource");
var hostingApplication = CreateApplication(out var features, diagnosticSource: diagnosticSource); var hostingApplication = CreateApplication(out var features, diagnosticListener: diagnosticListener);
bool startCalled = false; bool startCalled = false;
diagnosticSource.Subscribe(new CallbackDiagnosticListener(pair => diagnosticListener.Subscribe(new CallbackDiagnosticListener(pair =>
{ {
if (pair.Key == "Microsoft.AspNetCore.Hosting.HttpRequestIn.Start") if (pair.Key == "Microsoft.AspNetCore.Hosting.HttpRequestIn.Start")
{ {
@ -224,11 +224,11 @@ namespace Microsoft.AspNetCore.Hosting.Tests
[Fact] [Fact]
public void ActivityIsStoppedDuringStopCall() public void ActivityIsStoppedDuringStopCall()
{ {
var diagnosticSource = new DiagnosticListener("DummySource"); var diagnosticListener = new DiagnosticListener("DummySource");
var hostingApplication = CreateApplication(out var features, diagnosticSource: diagnosticSource); var hostingApplication = CreateApplication(out var features, diagnosticListener: diagnosticListener);
bool endCalled = false; bool endCalled = false;
diagnosticSource.Subscribe(new CallbackDiagnosticListener(pair => diagnosticListener.Subscribe(new CallbackDiagnosticListener(pair =>
{ {
if (pair.Key == "Microsoft.AspNetCore.Hosting.HttpRequestIn.Stop") if (pair.Key == "Microsoft.AspNetCore.Hosting.HttpRequestIn.Stop")
{ {
@ -249,11 +249,11 @@ namespace Microsoft.AspNetCore.Hosting.Tests
[Fact] [Fact]
public void ActivityIsStoppedDuringUnhandledExceptionCall() public void ActivityIsStoppedDuringUnhandledExceptionCall()
{ {
var diagnosticSource = new DiagnosticListener("DummySource"); var diagnosticListener = new DiagnosticListener("DummySource");
var hostingApplication = CreateApplication(out var features, diagnosticSource: diagnosticSource); var hostingApplication = CreateApplication(out var features, diagnosticListener: diagnosticListener);
bool endCalled = false; bool endCalled = false;
diagnosticSource.Subscribe(new CallbackDiagnosticListener(pair => diagnosticListener.Subscribe(new CallbackDiagnosticListener(pair =>
{ {
if (pair.Key == "Microsoft.AspNetCore.Hosting.HttpRequestIn.Stop") if (pair.Key == "Microsoft.AspNetCore.Hosting.HttpRequestIn.Stop")
{ {
@ -273,11 +273,11 @@ namespace Microsoft.AspNetCore.Hosting.Tests
[Fact] [Fact]
public void ActivityIsAvailableDuringUnhandledExceptionCall() public void ActivityIsAvailableDuringUnhandledExceptionCall()
{ {
var diagnosticSource = new DiagnosticListener("DummySource"); var diagnosticListener = new DiagnosticListener("DummySource");
var hostingApplication = CreateApplication(out var features, diagnosticSource: diagnosticSource); var hostingApplication = CreateApplication(out var features, diagnosticListener: diagnosticListener);
bool endCalled = false; bool endCalled = false;
diagnosticSource.Subscribe(new CallbackDiagnosticListener(pair => diagnosticListener.Subscribe(new CallbackDiagnosticListener(pair =>
{ {
if (pair.Key == "Microsoft.AspNetCore.Hosting.UnhandledException") if (pair.Key == "Microsoft.AspNetCore.Hosting.UnhandledException")
{ {
@ -295,10 +295,10 @@ namespace Microsoft.AspNetCore.Hosting.Tests
[Fact] [Fact]
public void ActivityIsAvailibleDuringRequest() public void ActivityIsAvailibleDuringRequest()
{ {
var diagnosticSource = new DiagnosticListener("DummySource"); var diagnosticListener = new DiagnosticListener("DummySource");
var hostingApplication = CreateApplication(out var features, diagnosticSource: diagnosticSource); var hostingApplication = CreateApplication(out var features, diagnosticListener: diagnosticListener);
diagnosticSource.Subscribe(new CallbackDiagnosticListener(pair => { }), diagnosticListener.Subscribe(new CallbackDiagnosticListener(pair => { }),
s => s =>
{ {
if (s.StartsWith("Microsoft.AspNetCore.Hosting.HttpRequestIn")) if (s.StartsWith("Microsoft.AspNetCore.Hosting.HttpRequestIn"))
@ -317,10 +317,10 @@ namespace Microsoft.AspNetCore.Hosting.Tests
[Fact] [Fact]
public void ActivityParentIdAndBaggeReadFromHeaders() public void ActivityParentIdAndBaggeReadFromHeaders()
{ {
var diagnosticSource = new DiagnosticListener("DummySource"); var diagnosticListener = new DiagnosticListener("DummySource");
var hostingApplication = CreateApplication(out var features, diagnosticSource: diagnosticSource); var hostingApplication = CreateApplication(out var features, diagnosticListener: diagnosticListener);
diagnosticSource.Subscribe(new CallbackDiagnosticListener(pair => { }), diagnosticListener.Subscribe(new CallbackDiagnosticListener(pair => { }),
s => s =>
{ {
if (s.StartsWith("Microsoft.AspNetCore.Hosting.HttpRequestIn")) if (s.StartsWith("Microsoft.AspNetCore.Hosting.HttpRequestIn"))
@ -349,10 +349,10 @@ namespace Microsoft.AspNetCore.Hosting.Tests
[Fact] [Fact]
public void ActivityTraceParentAndTraceStateFromHeaders() public void ActivityTraceParentAndTraceStateFromHeaders()
{ {
var diagnosticSource = new DiagnosticListener("DummySource"); var diagnosticListener = new DiagnosticListener("DummySource");
var hostingApplication = CreateApplication(out var features, diagnosticSource: diagnosticSource); var hostingApplication = CreateApplication(out var features, diagnosticListener: diagnosticListener);
diagnosticSource.Subscribe(new CallbackDiagnosticListener(pair => { }), diagnosticListener.Subscribe(new CallbackDiagnosticListener(pair => { }),
s => s =>
{ {
if (s.StartsWith("Microsoft.AspNetCore.Hosting.HttpRequestIn")) if (s.StartsWith("Microsoft.AspNetCore.Hosting.HttpRequestIn"))
@ -385,11 +385,11 @@ namespace Microsoft.AspNetCore.Hosting.Tests
[Fact] [Fact]
public void ActivityOnExportHookIsCalled() public void ActivityOnExportHookIsCalled()
{ {
var diagnosticSource = new DiagnosticListener("DummySource"); var diagnosticListener = new DiagnosticListener("DummySource");
var hostingApplication = CreateApplication(out var features, diagnosticSource: diagnosticSource); var hostingApplication = CreateApplication(out var features, diagnosticListener: diagnosticListener);
bool onActivityImportCalled = false; bool onActivityImportCalled = false;
diagnosticSource.Subscribe( diagnosticListener.Subscribe(
observer: new CallbackDiagnosticListener(pair => { }), observer: new CallbackDiagnosticListener(pair => { }),
isEnabled: (s, o, _) => true, isEnabled: (s, o, _) => true,
onActivityImport: (activity, context) => onActivityImport: (activity, context) =>
@ -422,7 +422,7 @@ namespace Microsoft.AspNetCore.Hosting.Tests
} }
private static HostingApplication CreateApplication(out FeatureCollection features, private static HostingApplication CreateApplication(out FeatureCollection features,
DiagnosticListener diagnosticSource = null, ILogger logger = null, Action<DefaultHttpContext> configure = null) DiagnosticListener diagnosticListener = null, ILogger logger = null, Action<DefaultHttpContext> configure = null)
{ {
var httpContextFactory = new Mock<IHttpContextFactory>(); var httpContextFactory = new Mock<IHttpContextFactory>();
@ -436,7 +436,7 @@ namespace Microsoft.AspNetCore.Hosting.Tests
var hostingApplication = new HostingApplication( var hostingApplication = new HostingApplication(
ctx => Task.CompletedTask, ctx => Task.CompletedTask,
logger ?? new NullScopeLogger(), logger ?? new NullScopeLogger(),
diagnosticSource ?? new NoopDiagnosticSource(), diagnosticListener ?? new NoopDiagnosticListener(),
httpContextFactory.Object); httpContextFactory.Object);
return hostingApplication; return hostingApplication;
@ -490,11 +490,11 @@ namespace Microsoft.AspNetCore.Hosting.Tests
} }
} }
private class NoopDiagnosticSource : DiagnosticListener private class NoopDiagnosticListener : DiagnosticListener
{ {
private readonly bool _isEnabled; private readonly bool _isEnabled;
public NoopDiagnosticSource(bool isEnabled = false) : base("DummyListener") public NoopDiagnosticListener(bool isEnabled = false) : base("DummyListener")
{ {
_isEnabled = isEnabled; _isEnabled = isEnabled;
} }

View File

@ -159,7 +159,7 @@ namespace Microsoft.AspNetCore.Http
// This property exists because of backwards compatibility. // This property exists because of backwards compatibility.
// We send an anonymous object with an HttpContext property // We send an anonymous object with an HttpContext property
// via DiagnosticSource in various events throughout the pipeline. Instead // via DiagnosticListener in various events throughout the pipeline. Instead
// we just send the HttpContext to avoid extra allocations // we just send the HttpContext to avoid extra allocations
[EditorBrowsable(EditorBrowsableState.Never)] [EditorBrowsable(EditorBrowsableState.Never)]
public HttpContext HttpContext => this; public HttpContext HttpContext => this;

View File

@ -1726,6 +1726,310 @@ namespace Microsoft.AspNetCore.Mvc.Core.Infrastructure
{ {
} }
} }
namespace Microsoft.AspNetCore.Mvc.Diagnostics
{
public sealed partial class AfterAction : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.AfterAction";
public AfterAction(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Http.HttpContext httpContext, Microsoft.AspNetCore.Routing.RouteData routeData) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Http.HttpContext HttpContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Routing.RouteData RouteData { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public sealed partial class AfterActionMethod : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.AfterActionMethod";
public AfterActionMethod(Microsoft.AspNetCore.Mvc.ActionContext actionContext, System.Collections.Generic.IReadOnlyDictionary<string, object> arguments, object controller, Microsoft.AspNetCore.Mvc.IActionResult result) { }
public Microsoft.AspNetCore.Mvc.ActionContext ActionContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public System.Collections.Generic.IReadOnlyDictionary<string, object> Arguments { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public object Controller { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Mvc.IActionResult Result { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public sealed partial class AfterActionResult : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.AfterActionResult";
public AfterActionResult(Microsoft.AspNetCore.Mvc.ActionContext actionContext, Microsoft.AspNetCore.Mvc.IActionResult result) { }
public Microsoft.AspNetCore.Mvc.ActionContext ActionContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Mvc.IActionResult Result { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public sealed partial class AfterOnActionExecuted : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.AfterOnActionExecuted";
public AfterOnActionExecuted(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.ActionExecutedContext actionExecutedContext, Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata filter) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.ActionExecutedContext ActionExecutedContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
}
public sealed partial class AfterOnActionExecuting : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.AfterOnActionExecuting";
public AfterOnActionExecuting(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.ActionExecutingContext actionExecutingContext, Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata filter) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.ActionExecutingContext ActionExecutingContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
}
public sealed partial class AfterOnActionExecution : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.AfterOnActionExecution";
public AfterOnActionExecution(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.ActionExecutedContext actionExecutedContext, Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata filter) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.ActionExecutedContext ActionExecutedContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
}
public sealed partial class AfterOnAuthorization : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.AfterOnAuthorization";
public AfterOnAuthorization(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.AuthorizationFilterContext authorizationContext, Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata filter) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.AuthorizationFilterContext AuthorizationContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
}
public sealed partial class AfterOnException : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.AfterOnException";
public AfterOnException(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.ExceptionContext exceptionContext, Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata filter) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.ExceptionContext ExceptionContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
}
public sealed partial class AfterOnResourceExecuted : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.AfterOnResourceExecuted";
public AfterOnResourceExecuted(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.ResourceExecutedContext resourceExecutedContext, Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata filter) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.ResourceExecutedContext ResourceExecutedContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public sealed partial class AfterOnResourceExecuting : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.AfterOnResourceExecuting";
public AfterOnResourceExecuting(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.ResourceExecutingContext resourceExecutingContext, Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata filter) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.ResourceExecutingContext ResourceExecutingContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public sealed partial class AfterOnResourceExecution : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.AfterOnResourceExecution";
public AfterOnResourceExecution(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.ResourceExecutedContext resourceExecutedContext, Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata filter) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.ResourceExecutedContext ResourceExecutedContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public sealed partial class AfterOnResultExecuted : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.AfterOnResultExecuted";
public AfterOnResultExecuted(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.ResultExecutedContext resultExecutedContext, Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata filter) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.ResultExecutedContext ResultExecutedContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public sealed partial class AfterOnResultExecuting : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.AfterOnResultExecuting";
public AfterOnResultExecuting(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.ResultExecutingContext resultExecutingContext, Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata filter) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.ResultExecutingContext ResultExecutingContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public sealed partial class AfterOnResultExecution : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.AfterOnResultExecution";
public AfterOnResultExecution(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.ResultExecutedContext resultExecutedContext, Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata filter) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.ResultExecutedContext ResultExecutedContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public sealed partial class BeforeAction : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.BeforeAction";
public BeforeAction(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Http.HttpContext httpContext, Microsoft.AspNetCore.Routing.RouteData routeData) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Http.HttpContext HttpContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Routing.RouteData RouteData { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public sealed partial class BeforeActionMethod : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.BeforeActionMethod";
public BeforeActionMethod(Microsoft.AspNetCore.Mvc.ActionContext actionContext, System.Collections.Generic.IReadOnlyDictionary<string, object> arguments, object controller) { }
public Microsoft.AspNetCore.Mvc.ActionContext ActionContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public System.Collections.Generic.IReadOnlyDictionary<string, object> Arguments { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public object Controller { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
}
public sealed partial class BeforeActionResult : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.BeforeActionResult";
public BeforeActionResult(Microsoft.AspNetCore.Mvc.ActionContext actionContext, Microsoft.AspNetCore.Mvc.IActionResult result) { }
public Microsoft.AspNetCore.Mvc.ActionContext ActionContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Mvc.IActionResult Result { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public sealed partial class BeforeOnActionExecuted : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.BeforeOnActionExecuted";
public BeforeOnActionExecuted(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.ActionExecutedContext actionExecutedContext, Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata filter) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.ActionExecutedContext ActionExecutedContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
}
public sealed partial class BeforeOnActionExecuting : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.BeforeOnActionExecuting";
public BeforeOnActionExecuting(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.ActionExecutingContext actionExecutingContext, Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata filter) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.ActionExecutingContext ActionExecutingContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
}
public sealed partial class BeforeOnActionExecution : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.BeforeOnActionExecution";
public BeforeOnActionExecution(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.ActionExecutingContext actionExecutingContext, Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata filter) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.ActionExecutingContext ActionExecutingContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
}
public sealed partial class BeforeOnAuthorization : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.BeforeOnAuthorization";
public BeforeOnAuthorization(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.AuthorizationFilterContext authorizationContext, Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata filter) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.AuthorizationFilterContext AuthorizationContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
}
public sealed partial class BeforeOnException : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.BeforeOnException";
public BeforeOnException(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.ExceptionContext exceptionContext, Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata filter) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.ExceptionContext ExceptionContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
}
public sealed partial class BeforeOnResourceExecuted : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.BeforeOnResourceExecuted";
public BeforeOnResourceExecuted(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.ResourceExecutedContext resourceExecutedContext, Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata filter) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.ResourceExecutedContext ResourceExecutedContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public sealed partial class BeforeOnResourceExecuting : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.BeforeOnResourceExecuting";
public BeforeOnResourceExecuting(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.ResourceExecutingContext resourceExecutingContext, Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata filter) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.ResourceExecutingContext ResourceExecutingContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public sealed partial class BeforeOnResourceExecution : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.BeforeOnResourceExecution";
public BeforeOnResourceExecution(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.ResourceExecutingContext resourceExecutingContext, Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata filter) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.ResourceExecutingContext ResourceExecutingContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public sealed partial class BeforeOnResultExecuted : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.BeforeOnResultExecuted";
public BeforeOnResultExecuted(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.ResultExecutedContext resultExecutedContext, Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata filter) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.ResultExecutedContext ResultExecutedContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public sealed partial class BeforeOnResultExecuting : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.BeforeOnResultExecuting";
public BeforeOnResultExecuting(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.ResultExecutingContext resultExecutingContext, Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata filter) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.ResultExecutingContext ResultExecutingContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public sealed partial class BeforeOnResultExecution : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.BeforeOnResultExecution";
public BeforeOnResultExecution(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.ResultExecutingContext resultExecutingContext, Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata filter) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.ResultExecutingContext ResultExecutingContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public abstract partial class EventData : System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<string, object>>, System.Collections.Generic.IReadOnlyCollection<System.Collections.Generic.KeyValuePair<string, object>>, System.Collections.Generic.IReadOnlyList<System.Collections.Generic.KeyValuePair<string, object>>, System.Collections.IEnumerable
{
protected const string EventNamespace = "Microsoft.AspNetCore.Mvc.";
protected EventData() { }
protected abstract int Count { get; }
protected abstract System.Collections.Generic.KeyValuePair<string, object> this[int index] { get; }
int System.Collections.Generic.IReadOnlyCollection<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.Count { get { throw null; } }
System.Collections.Generic.KeyValuePair<string, object> System.Collections.Generic.IReadOnlyList<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.this[int index] { get { throw null; } }
System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<string, object>> System.Collections.Generic.IEnumerable<System.Collections.Generic.KeyValuePair<System.String,System.Object>>.GetEnumerator() { throw null; }
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; }
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public partial struct Enumerator : System.Collections.Generic.IEnumerator<System.Collections.Generic.KeyValuePair<string, object>>, System.Collections.IEnumerator, System.IDisposable
{
private object _dummy;
private int _dummyPrimitive;
public System.Collections.Generic.KeyValuePair<string, object> Current { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
object System.Collections.IEnumerator.Current { get { throw null; } }
public void Dispose() { }
public bool MoveNext() { throw null; }
void System.Collections.IEnumerator.Reset() { }
}
}
}
namespace Microsoft.AspNetCore.Mvc.Filters namespace Microsoft.AspNetCore.Mvc.Filters
{ {
[System.AttributeUsageAttribute(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true, Inherited=true)] [System.AttributeUsageAttribute(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true, Inherited=true)]

View File

@ -0,0 +1,64 @@
// 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.Collections;
using System.Collections.Generic;
namespace Microsoft.AspNetCore.Mvc.Diagnostics
{
public abstract class EventData : IReadOnlyList<KeyValuePair<string, object>>
{
protected const string EventNamespace = "Microsoft.AspNetCore.Mvc.";
protected abstract int Count { get; }
protected abstract KeyValuePair<string, object> this[int index] { get; }
int IReadOnlyCollection<KeyValuePair<string, object>>.Count => Count;
KeyValuePair<string, object> IReadOnlyList<KeyValuePair<string, object>>.this[int index] => this[index];
Enumerator GetEnumerator() => new Enumerator(this);
IEnumerator<KeyValuePair<string, object>> IEnumerable<KeyValuePair<string, object>>.GetEnumerator()
=> GetEnumerator();
IEnumerator IEnumerable.GetEnumerator()
=> GetEnumerator();
public struct Enumerator : IEnumerator<KeyValuePair<string, object>>
{
private readonly EventData _eventData;
private readonly int _count;
private int _index;
public KeyValuePair<string, object> Current { get; private set; }
internal Enumerator(EventData eventData)
{
_eventData = eventData;
_count = eventData.Count;
_index = -1;
Current = default;
}
public bool MoveNext()
{
var index = _index + 1;
if (index >= _count)
{
return false;
}
_index = index;
Current = _eventData[index];
return true;
}
public void Dispose() { }
object IEnumerator.Current => Current;
void IEnumerator.Reset() => throw new NotSupportedException();
}
}
}

View File

@ -0,0 +1,736 @@
// 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.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Routing;
namespace Microsoft.AspNetCore.Mvc.Diagnostics
{
public sealed class BeforeAction : EventData
{
public const string EventName = EventNamespace + nameof(BeforeAction);
public BeforeAction(ActionDescriptor actionDescriptor, HttpContext httpContext, RouteData routeData)
{
ActionDescriptor = actionDescriptor;
HttpContext = httpContext;
RouteData = routeData;
}
public ActionDescriptor ActionDescriptor { get; }
public HttpContext HttpContext { get; }
public RouteData RouteData { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(HttpContext), HttpContext),
2 => new KeyValuePair<string, object>(nameof(RouteData), RouteData),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class AfterAction : EventData
{
public const string EventName = EventNamespace + nameof(AfterAction);
public AfterAction(ActionDescriptor actionDescriptor, HttpContext httpContext, RouteData routeData)
{
ActionDescriptor = actionDescriptor;
HttpContext = httpContext;
RouteData = routeData;
}
public ActionDescriptor ActionDescriptor { get; }
public HttpContext HttpContext { get; }
public RouteData RouteData { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(HttpContext), HttpContext),
2 => new KeyValuePair<string, object>(nameof(RouteData), RouteData),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class BeforeOnAuthorization : EventData
{
public const string EventName = EventNamespace + nameof(BeforeOnAuthorization);
public BeforeOnAuthorization(ActionDescriptor actionDescriptor, AuthorizationFilterContext authorizationContext, IFilterMetadata filter)
{
ActionDescriptor = actionDescriptor;
AuthorizationContext = authorizationContext;
Filter = filter;
}
public ActionDescriptor ActionDescriptor { get; }
public AuthorizationFilterContext AuthorizationContext { get; }
public IFilterMetadata Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(AuthorizationContext), AuthorizationContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class AfterOnAuthorization : EventData
{
public const string EventName = EventNamespace + nameof(AfterOnAuthorization);
public AfterOnAuthorization(ActionDescriptor actionDescriptor, AuthorizationFilterContext authorizationContext, IFilterMetadata filter)
{
ActionDescriptor = actionDescriptor;
AuthorizationContext = authorizationContext;
Filter = filter;
}
public ActionDescriptor ActionDescriptor { get; }
public AuthorizationFilterContext AuthorizationContext { get; }
public IFilterMetadata Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(AuthorizationContext), AuthorizationContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class BeforeOnResourceExecution : EventData
{
public const string EventName = EventNamespace + nameof(BeforeOnResourceExecution);
public BeforeOnResourceExecution(ActionDescriptor actionDescriptor, ResourceExecutingContext resourceExecutingContext, IFilterMetadata filter)
{
ActionDescriptor = actionDescriptor;
ResourceExecutingContext = resourceExecutingContext;
Filter = filter;
}
public ActionDescriptor ActionDescriptor { get; }
public ResourceExecutingContext ResourceExecutingContext { get; }
public IFilterMetadata Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(ResourceExecutingContext), ResourceExecutingContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class AfterOnResourceExecution : EventData
{
public const string EventName = EventNamespace + nameof(AfterOnResourceExecution);
public AfterOnResourceExecution(ActionDescriptor actionDescriptor, ResourceExecutedContext resourceExecutedContext, IFilterMetadata filter)
{
ActionDescriptor = actionDescriptor;
ResourceExecutedContext = resourceExecutedContext;
Filter = filter;
}
public ActionDescriptor ActionDescriptor { get; }
public ResourceExecutedContext ResourceExecutedContext { get; }
public IFilterMetadata Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(ResourceExecutedContext), ResourceExecutedContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class BeforeOnResourceExecuting : EventData
{
public const string EventName = EventNamespace + nameof(BeforeOnResourceExecuting);
public BeforeOnResourceExecuting(ActionDescriptor actionDescriptor, ResourceExecutingContext resourceExecutingContext, IFilterMetadata filter)
{
ActionDescriptor = actionDescriptor;
ResourceExecutingContext = resourceExecutingContext;
Filter = filter;
}
public ActionDescriptor ActionDescriptor { get; }
public ResourceExecutingContext ResourceExecutingContext { get; }
public IFilterMetadata Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(ResourceExecutingContext), ResourceExecutingContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class AfterOnResourceExecuting : EventData
{
public const string EventName = EventNamespace + nameof(AfterOnResourceExecuting);
public AfterOnResourceExecuting(ActionDescriptor actionDescriptor, ResourceExecutingContext resourceExecutingContext, IFilterMetadata filter)
{
ActionDescriptor = actionDescriptor;
ResourceExecutingContext = resourceExecutingContext;
Filter = filter;
}
public ActionDescriptor ActionDescriptor { get; }
public ResourceExecutingContext ResourceExecutingContext { get; }
public IFilterMetadata Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(ResourceExecutingContext), ResourceExecutingContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class BeforeOnResourceExecuted : EventData
{
public const string EventName = EventNamespace + nameof(BeforeOnResourceExecuted);
public BeforeOnResourceExecuted(ActionDescriptor actionDescriptor, ResourceExecutedContext resourceExecutedContext, IFilterMetadata filter)
{
ActionDescriptor = actionDescriptor;
ResourceExecutedContext = resourceExecutedContext;
Filter = filter;
}
public ActionDescriptor ActionDescriptor { get; }
public ResourceExecutedContext ResourceExecutedContext { get; }
public IFilterMetadata Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(ResourceExecutedContext), ResourceExecutedContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class AfterOnResourceExecuted : EventData
{
public const string EventName = EventNamespace + nameof(AfterOnResourceExecuted);
public AfterOnResourceExecuted(ActionDescriptor actionDescriptor, ResourceExecutedContext resourceExecutedContext, IFilterMetadata filter)
{
ActionDescriptor = actionDescriptor;
ResourceExecutedContext = resourceExecutedContext;
Filter = filter;
}
public ActionDescriptor ActionDescriptor { get; }
public ResourceExecutedContext ResourceExecutedContext { get; }
public IFilterMetadata Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(ResourceExecutedContext), ResourceExecutedContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class BeforeOnException : EventData
{
public const string EventName = EventNamespace + nameof(BeforeOnException);
public BeforeOnException(ActionDescriptor actionDescriptor, ExceptionContext exceptionContext, IFilterMetadata filter)
{
ActionDescriptor = actionDescriptor;
ExceptionContext = exceptionContext;
Filter = filter;
}
public ActionDescriptor ActionDescriptor { get; }
public ExceptionContext ExceptionContext { get; }
public IFilterMetadata Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(ExceptionContext), ExceptionContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class AfterOnException : EventData
{
public const string EventName = EventNamespace + nameof(AfterOnException);
public AfterOnException(ActionDescriptor actionDescriptor, ExceptionContext exceptionContext, IFilterMetadata filter)
{
ActionDescriptor = actionDescriptor;
ExceptionContext = exceptionContext;
Filter = filter;
}
public ActionDescriptor ActionDescriptor { get; }
public ExceptionContext ExceptionContext { get; }
public IFilterMetadata Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(ExceptionContext), ExceptionContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class BeforeOnActionExecution : EventData
{
public const string EventName = EventNamespace + nameof(BeforeOnActionExecution);
public BeforeOnActionExecution(ActionDescriptor actionDescriptor, ActionExecutingContext actionExecutingContext, IFilterMetadata filter)
{
ActionDescriptor = actionDescriptor;
ActionExecutingContext = actionExecutingContext;
Filter = filter;
}
public ActionDescriptor ActionDescriptor { get; }
public ActionExecutingContext ActionExecutingContext { get; }
public IFilterMetadata Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(ActionExecutingContext), ActionExecutingContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class AfterOnActionExecution : EventData
{
public const string EventName = EventNamespace + nameof(AfterOnActionExecution);
public AfterOnActionExecution(ActionDescriptor actionDescriptor, ActionExecutedContext actionExecutedContext, IFilterMetadata filter)
{
ActionDescriptor = actionDescriptor;
ActionExecutedContext = actionExecutedContext;
Filter = filter;
}
public ActionDescriptor ActionDescriptor { get; }
public ActionExecutedContext ActionExecutedContext { get; }
public IFilterMetadata Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(ActionExecutedContext), ActionExecutedContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class BeforeOnActionExecuting : EventData
{
public const string EventName = EventNamespace + nameof(BeforeOnActionExecuting);
public BeforeOnActionExecuting(ActionDescriptor actionDescriptor, ActionExecutingContext actionExecutingContext, IFilterMetadata filter)
{
ActionDescriptor = actionDescriptor;
ActionExecutingContext = actionExecutingContext;
Filter = filter;
}
public ActionDescriptor ActionDescriptor { get; }
public ActionExecutingContext ActionExecutingContext { get; }
public IFilterMetadata Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(ActionExecutingContext), ActionExecutingContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class AfterOnActionExecuting : EventData
{
public const string EventName = EventNamespace + nameof(AfterOnActionExecuting);
public AfterOnActionExecuting(ActionDescriptor actionDescriptor, ActionExecutingContext actionExecutingContext, IFilterMetadata filter)
{
ActionDescriptor = actionDescriptor;
ActionExecutingContext = actionExecutingContext;
Filter = filter;
}
public ActionDescriptor ActionDescriptor { get; }
public ActionExecutingContext ActionExecutingContext { get; }
public IFilterMetadata Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(ActionExecutingContext), ActionExecutingContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class BeforeOnActionExecuted : EventData
{
public const string EventName = EventNamespace + nameof(BeforeOnActionExecuted);
public BeforeOnActionExecuted(ActionDescriptor actionDescriptor, ActionExecutedContext actionExecutedContext, IFilterMetadata filter)
{
ActionDescriptor = actionDescriptor;
ActionExecutedContext = actionExecutedContext;
Filter = filter;
}
public ActionDescriptor ActionDescriptor { get; }
public ActionExecutedContext ActionExecutedContext { get; }
public IFilterMetadata Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(ActionExecutedContext), ActionExecutedContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class AfterOnActionExecuted : EventData
{
public const string EventName = EventNamespace + nameof(AfterOnActionExecuted);
public AfterOnActionExecuted(ActionDescriptor actionDescriptor, ActionExecutedContext actionExecutedContext, IFilterMetadata filter)
{
ActionDescriptor = actionDescriptor;
ActionExecutedContext = actionExecutedContext;
Filter = filter;
}
public ActionDescriptor ActionDescriptor { get; }
public ActionExecutedContext ActionExecutedContext { get; }
public IFilterMetadata Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(ActionExecutedContext), ActionExecutedContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class BeforeActionMethod : EventData
{
public const string EventName = EventNamespace + nameof(BeforeActionMethod);
public BeforeActionMethod(ActionContext actionContext, IReadOnlyDictionary<string, object> arguments, object controller)
{
ActionContext = actionContext;
Arguments = arguments;
Controller = controller;
}
public ActionContext ActionContext { get; }
public IReadOnlyDictionary<string, object> Arguments { get; }
public object Controller { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionContext), ActionContext),
1 => new KeyValuePair<string, object>(nameof(Arguments), Arguments),
2 => new KeyValuePair<string, object>(nameof(Controller), Controller),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class AfterActionMethod : EventData
{
public const string EventName = EventNamespace + nameof(AfterActionMethod);
public AfterActionMethod(ActionContext actionContext, IReadOnlyDictionary<string, object> arguments, object controller, IActionResult result)
{
ActionContext = actionContext;
Arguments = arguments;
Controller = controller;
Result = result;
}
public ActionContext ActionContext { get; }
public IReadOnlyDictionary<string, object> Arguments { get; }
public object Controller { get; }
public IActionResult Result { get; }
protected override int Count => 4;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionContext), ActionContext),
1 => new KeyValuePair<string, object>(nameof(Controller), Controller),
2 => new KeyValuePair<string, object>(nameof(Controller), Controller),
3 => new KeyValuePair<string, object>(nameof(Result), Result),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class BeforeOnResultExecution : EventData
{
public const string EventName = EventNamespace + nameof(BeforeOnResultExecution);
public BeforeOnResultExecution(ActionDescriptor actionDescriptor, ResultExecutingContext resultExecutingContext, IFilterMetadata filter)
{
ActionDescriptor = actionDescriptor;
ResultExecutingContext = resultExecutingContext;
Filter = filter;
}
public ActionDescriptor ActionDescriptor { get; }
public ResultExecutingContext ResultExecutingContext { get; }
public IFilterMetadata Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(ResultExecutingContext), ResultExecutingContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class AfterOnResultExecution : EventData
{
public const string EventName = EventNamespace + nameof(AfterOnResultExecution);
public AfterOnResultExecution(ActionDescriptor actionDescriptor, ResultExecutedContext resultExecutedContext, IFilterMetadata filter)
{
ActionDescriptor = actionDescriptor;
ResultExecutedContext = resultExecutedContext;
Filter = filter;
}
public ActionDescriptor ActionDescriptor { get; }
public ResultExecutedContext ResultExecutedContext { get; }
public IFilterMetadata Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(ResultExecutedContext), ResultExecutedContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class BeforeOnResultExecuting : EventData
{
public const string EventName = EventNamespace + nameof(BeforeOnResultExecuting);
public BeforeOnResultExecuting(ActionDescriptor actionDescriptor, ResultExecutingContext resultExecutingContext, IFilterMetadata filter)
{
ActionDescriptor = actionDescriptor;
ResultExecutingContext = resultExecutingContext;
Filter = filter;
}
public ActionDescriptor ActionDescriptor { get; }
public ResultExecutingContext ResultExecutingContext { get; }
public IFilterMetadata Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(ResultExecutingContext), ResultExecutingContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class AfterOnResultExecuting : EventData
{
public const string EventName = EventNamespace + nameof(AfterOnResultExecuting);
public AfterOnResultExecuting(ActionDescriptor actionDescriptor, ResultExecutingContext resultExecutingContext, IFilterMetadata filter)
{
ActionDescriptor = actionDescriptor;
ResultExecutingContext = resultExecutingContext;
Filter = filter;
}
public ActionDescriptor ActionDescriptor { get; }
public ResultExecutingContext ResultExecutingContext { get; }
public IFilterMetadata Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(ResultExecutingContext), ResultExecutingContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class BeforeOnResultExecuted : EventData
{
public const string EventName = EventNamespace + nameof(BeforeOnResultExecuted);
public BeforeOnResultExecuted(ActionDescriptor actionDescriptor, ResultExecutedContext resultExecutedContext, IFilterMetadata filter)
{
ActionDescriptor = actionDescriptor;
ResultExecutedContext = resultExecutedContext;
Filter = filter;
}
public ActionDescriptor ActionDescriptor { get; }
public ResultExecutedContext ResultExecutedContext { get; }
public IFilterMetadata Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(ResultExecutedContext), ResultExecutedContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class AfterOnResultExecuted : EventData
{
public const string EventName = EventNamespace + nameof(AfterOnResultExecuted);
public AfterOnResultExecuted(ActionDescriptor actionDescriptor, ResultExecutedContext resultExecutedContext, IFilterMetadata filter)
{
ActionDescriptor = actionDescriptor;
ResultExecutedContext = resultExecutedContext;
Filter = filter;
}
public ActionDescriptor ActionDescriptor { get; }
public ResultExecutedContext ResultExecutedContext { get; }
public IFilterMetadata Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(ResultExecutedContext), ResultExecutedContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class BeforeActionResult : EventData
{
public const string EventName = EventNamespace + nameof(BeforeActionResult);
public BeforeActionResult(ActionContext actionContext, IActionResult result)
{
ActionContext = actionContext;
Result = result;
}
public ActionContext ActionContext { get; }
public IActionResult Result { get; }
protected override int Count => 2;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionContext), ActionContext),
1 => new KeyValuePair<string, object>(nameof(Result), Result),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class AfterActionResult : EventData
{
public const string EventName = EventNamespace + nameof(AfterActionResult);
public AfterActionResult(ActionContext actionContext, IActionResult result)
{
ActionContext = actionContext;
Result = result;
}
public ActionContext ActionContext { get; }
public IActionResult Result { get; }
protected override int Count => 2;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionContext), ActionContext),
1 => new KeyValuePair<string, object>(nameof(Result), Result),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
}

View File

@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Abstractions; using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Diagnostics;
using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Routing; using Microsoft.AspNetCore.Routing;
@ -13,7 +14,7 @@ namespace Microsoft.AspNetCore.Mvc
// We're doing a lot of asserts here because these methods are really tedious to test and // We're doing a lot of asserts here because these methods are really tedious to test and
// highly dependent on the details of the invoker's state machine. Basically if we wrote the // highly dependent on the details of the invoker's state machine. Basically if we wrote the
// obvious unit tests that would generate a lot of boilerplate and wouldn't cover the hard parts. // obvious unit tests that would generate a lot of boilerplate and wouldn't cover the hard parts.
internal static class MvcCoreDiagnosticSourceExtensions internal static class MvcCoreDiagnosticListenerExtensions
{ {
public static void BeforeAction( public static void BeforeAction(
this DiagnosticListener diagnosticListener, this DiagnosticListener diagnosticListener,
@ -35,11 +36,11 @@ namespace Microsoft.AspNetCore.Mvc
private static void BeforeActionImpl(DiagnosticListener diagnosticListener, ActionDescriptor actionDescriptor, HttpContext httpContext, RouteData routeData) private static void BeforeActionImpl(DiagnosticListener diagnosticListener, ActionDescriptor actionDescriptor, HttpContext httpContext, RouteData routeData)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeAction")) if (diagnosticListener.IsEnabled(Diagnostics.BeforeAction.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeAction", Diagnostics.BeforeAction.EventName,
new { actionDescriptor, httpContext = httpContext, routeData = routeData }); new BeforeAction(actionDescriptor, httpContext, routeData));
} }
} }
@ -63,11 +64,11 @@ namespace Microsoft.AspNetCore.Mvc
private static void AfterActionImpl(DiagnosticListener diagnosticListener, ActionDescriptor actionDescriptor, HttpContext httpContext, RouteData routeData) private static void AfterActionImpl(DiagnosticListener diagnosticListener, ActionDescriptor actionDescriptor, HttpContext httpContext, RouteData routeData)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterAction")) if (diagnosticListener.IsEnabled(Diagnostics.AfterAction.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterAction", Diagnostics.AfterAction.EventName,
new { actionDescriptor, httpContext = httpContext, routeData = routeData }); new AfterAction(actionDescriptor, httpContext, routeData));
} }
} }
@ -89,16 +90,15 @@ namespace Microsoft.AspNetCore.Mvc
private static void BeforeOnAuthorizationAsyncImpl(DiagnosticListener diagnosticListener, AuthorizationFilterContext authorizationContext, IAsyncAuthorizationFilter filter) private static void BeforeOnAuthorizationAsyncImpl(DiagnosticListener diagnosticListener, AuthorizationFilterContext authorizationContext, IAsyncAuthorizationFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnAuthorization")) if (diagnosticListener.IsEnabled(Diagnostics.BeforeOnAuthorization.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnAuthorization", Diagnostics.BeforeOnAuthorization.EventName,
new new BeforeOnAuthorization(
{ authorizationContext.ActionDescriptor,
actionDescriptor = authorizationContext.ActionDescriptor, authorizationContext,
authorizationContext = authorizationContext, filter
filter = filter ));
});
} }
} }
@ -120,16 +120,15 @@ namespace Microsoft.AspNetCore.Mvc
private static void AfterOnAuthorizationAsyncImpl(DiagnosticListener diagnosticListener, AuthorizationFilterContext authorizationContext, IAsyncAuthorizationFilter filter) private static void AfterOnAuthorizationAsyncImpl(DiagnosticListener diagnosticListener, AuthorizationFilterContext authorizationContext, IAsyncAuthorizationFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnAuthorization")) if (diagnosticListener.IsEnabled(Diagnostics.AfterOnAuthorization.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnAuthorization", Diagnostics.AfterOnAuthorization.EventName,
new new AfterOnAuthorization(
{ authorizationContext.ActionDescriptor,
actionDescriptor = authorizationContext.ActionDescriptor, authorizationContext,
authorizationContext = authorizationContext, filter
filter = filter ));
});
} }
} }
@ -151,16 +150,15 @@ namespace Microsoft.AspNetCore.Mvc
private static void BeforeOnAuthorizationImpl(DiagnosticListener diagnosticListener, AuthorizationFilterContext authorizationContext, IAuthorizationFilter filter) private static void BeforeOnAuthorizationImpl(DiagnosticListener diagnosticListener, AuthorizationFilterContext authorizationContext, IAuthorizationFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnAuthorization")) if (diagnosticListener.IsEnabled(Diagnostics.BeforeOnAuthorization.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnAuthorization", Diagnostics.BeforeOnAuthorization.EventName,
new new BeforeOnAuthorization(
{ authorizationContext.ActionDescriptor,
actionDescriptor = authorizationContext.ActionDescriptor, authorizationContext,
authorizationContext = authorizationContext, filter
filter = filter ));
});
} }
} }
@ -182,16 +180,15 @@ namespace Microsoft.AspNetCore.Mvc
private static void AfterOnAuthorizationImpl(DiagnosticListener diagnosticListener, AuthorizationFilterContext authorizationContext, IAuthorizationFilter filter) private static void AfterOnAuthorizationImpl(DiagnosticListener diagnosticListener, AuthorizationFilterContext authorizationContext, IAuthorizationFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnAuthorization")) if (diagnosticListener.IsEnabled(Diagnostics.AfterOnAuthorization.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnAuthorization", Diagnostics.AfterOnAuthorization.EventName,
new new AfterOnAuthorization(
{ authorizationContext.ActionDescriptor,
actionDescriptor = authorizationContext.ActionDescriptor, authorizationContext,
authorizationContext = authorizationContext, filter
filter = filter ));
});
} }
} }
@ -213,16 +210,15 @@ namespace Microsoft.AspNetCore.Mvc
private static void BeforeOnResourceExecutionImpl(DiagnosticListener diagnosticListener, ResourceExecutingContext resourceExecutingContext, IAsyncResourceFilter filter) private static void BeforeOnResourceExecutionImpl(DiagnosticListener diagnosticListener, ResourceExecutingContext resourceExecutingContext, IAsyncResourceFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResourceExecution")) if (diagnosticListener.IsEnabled(Diagnostics.BeforeOnResourceExecution.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnResourceExecution", Diagnostics.BeforeOnResourceExecution.EventName,
new new BeforeOnResourceExecution(
{ resourceExecutingContext.ActionDescriptor,
actionDescriptor = resourceExecutingContext.ActionDescriptor, resourceExecutingContext,
resourceExecutingContext = resourceExecutingContext, filter
filter = filter ));
});
} }
} }
@ -244,16 +240,15 @@ namespace Microsoft.AspNetCore.Mvc
private static void AfterOnResourceExecutionImpl(DiagnosticListener diagnosticListener, ResourceExecutedContext resourceExecutedContext, IAsyncResourceFilter filter) private static void AfterOnResourceExecutionImpl(DiagnosticListener diagnosticListener, ResourceExecutedContext resourceExecutedContext, IAsyncResourceFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResourceExecution")) if (diagnosticListener.IsEnabled(Diagnostics.AfterOnResourceExecution.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnResourceExecution", Diagnostics.AfterOnResourceExecution.EventName,
new new AfterOnResourceExecution(
{ resourceExecutedContext.ActionDescriptor,
actionDescriptor = resourceExecutedContext.ActionDescriptor, resourceExecutedContext,
resourceExecutedContext = resourceExecutedContext, filter
filter = filter ));
});
} }
} }
@ -275,16 +270,15 @@ namespace Microsoft.AspNetCore.Mvc
private static void BeforeOnResourceExecutingImpl(DiagnosticListener diagnosticListener, ResourceExecutingContext resourceExecutingContext, IResourceFilter filter) private static void BeforeOnResourceExecutingImpl(DiagnosticListener diagnosticListener, ResourceExecutingContext resourceExecutingContext, IResourceFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResourceExecuting")) if (diagnosticListener.IsEnabled(Diagnostics.BeforeOnResourceExecuting.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnResourceExecuting", Diagnostics.BeforeOnResourceExecuting.EventName,
new new BeforeOnResourceExecuting(
{ resourceExecutingContext.ActionDescriptor,
actionDescriptor = resourceExecutingContext.ActionDescriptor, resourceExecutingContext,
resourceExecutingContext = resourceExecutingContext, filter
filter = filter ));
});
} }
} }
@ -306,16 +300,15 @@ namespace Microsoft.AspNetCore.Mvc
private static void AfterOnResourceExecutingImpl(DiagnosticListener diagnosticListener, ResourceExecutingContext resourceExecutingContext, IResourceFilter filter) private static void AfterOnResourceExecutingImpl(DiagnosticListener diagnosticListener, ResourceExecutingContext resourceExecutingContext, IResourceFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResourceExecuting")) if (diagnosticListener.IsEnabled(Diagnostics.AfterOnResourceExecuting.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnResourceExecuting", Diagnostics.AfterOnResourceExecuting.EventName,
new new AfterOnResourceExecuting(
{ resourceExecutingContext.ActionDescriptor,
actionDescriptor = resourceExecutingContext.ActionDescriptor, resourceExecutingContext,
resourceExecutingContext = resourceExecutingContext, filter
filter = filter ));
});
} }
} }
@ -337,16 +330,15 @@ namespace Microsoft.AspNetCore.Mvc
private static void BeforeOnResourceExecutedImpl(DiagnosticListener diagnosticListener, ResourceExecutedContext resourceExecutedContext, IResourceFilter filter) private static void BeforeOnResourceExecutedImpl(DiagnosticListener diagnosticListener, ResourceExecutedContext resourceExecutedContext, IResourceFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResourceExecuted")) if (diagnosticListener.IsEnabled(Diagnostics.BeforeOnResourceExecuted.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnResourceExecuted", Diagnostics.BeforeOnResourceExecuted.EventName,
new new BeforeOnResourceExecuted(
{ resourceExecutedContext.ActionDescriptor,
actionDescriptor = resourceExecutedContext.ActionDescriptor, resourceExecutedContext,
resourceExecutedContext = resourceExecutedContext, filter
filter = filter ));
});
} }
} }
@ -368,16 +360,15 @@ namespace Microsoft.AspNetCore.Mvc
private static void AfterOnResourceExecutedImpl(DiagnosticListener diagnosticListener, ResourceExecutedContext resourceExecutedContext, IResourceFilter filter) private static void AfterOnResourceExecutedImpl(DiagnosticListener diagnosticListener, ResourceExecutedContext resourceExecutedContext, IResourceFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResourceExecuted")) if (diagnosticListener.IsEnabled(Diagnostics.AfterOnResourceExecuted.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnResourceExecuted", Diagnostics.AfterOnResourceExecuted.EventName,
new new AfterOnResourceExecuted(
{ resourceExecutedContext.ActionDescriptor,
actionDescriptor = resourceExecutedContext.ActionDescriptor, resourceExecutedContext,
resourceExecutedContext = resourceExecutedContext, filter
filter = filter ));
});
} }
} }
@ -399,16 +390,15 @@ namespace Microsoft.AspNetCore.Mvc
private static void BeforeOnExceptionAsyncImpl(DiagnosticListener diagnosticListener, ExceptionContext exceptionContext, IAsyncExceptionFilter filter) private static void BeforeOnExceptionAsyncImpl(DiagnosticListener diagnosticListener, ExceptionContext exceptionContext, IAsyncExceptionFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnException")) if (diagnosticListener.IsEnabled(Diagnostics.BeforeOnException.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnException", Diagnostics.BeforeOnException.EventName,
new new BeforeOnException(
{ exceptionContext.ActionDescriptor,
actionDescriptor = exceptionContext.ActionDescriptor, exceptionContext,
exceptionContext = exceptionContext, filter
filter = filter ));
});
} }
} }
@ -430,16 +420,15 @@ namespace Microsoft.AspNetCore.Mvc
private static void AfterOnExceptionAsyncImpl(DiagnosticListener diagnosticListener, ExceptionContext exceptionContext, IAsyncExceptionFilter filter) private static void AfterOnExceptionAsyncImpl(DiagnosticListener diagnosticListener, ExceptionContext exceptionContext, IAsyncExceptionFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnException")) if (diagnosticListener.IsEnabled(Diagnostics.AfterOnException.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnException", Diagnostics.AfterOnException.EventName,
new new AfterOnException(
{ exceptionContext.ActionDescriptor,
actionDescriptor = exceptionContext.ActionDescriptor, exceptionContext,
exceptionContext = exceptionContext, filter
filter = filter ));
});
} }
} }
@ -461,16 +450,15 @@ namespace Microsoft.AspNetCore.Mvc
private static void BeforeOnExceptionImpl(DiagnosticListener diagnosticListener, ExceptionContext exceptionContext, IExceptionFilter filter) private static void BeforeOnExceptionImpl(DiagnosticListener diagnosticListener, ExceptionContext exceptionContext, IExceptionFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnException")) if (diagnosticListener.IsEnabled(Diagnostics.BeforeOnException.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnException", Diagnostics.BeforeOnException.EventName,
new new BeforeOnException(
{ exceptionContext.ActionDescriptor,
actionDescriptor = exceptionContext.ActionDescriptor, exceptionContext,
exceptionContext = exceptionContext, filter
filter = filter ));
});
} }
} }
@ -492,16 +480,15 @@ namespace Microsoft.AspNetCore.Mvc
private static void AfterOnExceptionImpl(DiagnosticListener diagnosticListener, ExceptionContext exceptionContext, IExceptionFilter filter) private static void AfterOnExceptionImpl(DiagnosticListener diagnosticListener, ExceptionContext exceptionContext, IExceptionFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnException")) if (diagnosticListener.IsEnabled(Diagnostics.AfterOnException.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnException", Diagnostics.AfterOnException.EventName,
new new AfterOnException(
{ exceptionContext.ActionDescriptor,
actionDescriptor = exceptionContext.ActionDescriptor, exceptionContext,
exceptionContext = exceptionContext, filter
filter = filter ));
});
} }
} }
@ -523,16 +510,15 @@ namespace Microsoft.AspNetCore.Mvc
private static void BeforeOnActionExecutionImpl(DiagnosticListener diagnosticListener, ActionExecutingContext actionExecutingContext, IAsyncActionFilter filter) private static void BeforeOnActionExecutionImpl(DiagnosticListener diagnosticListener, ActionExecutingContext actionExecutingContext, IAsyncActionFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnActionExecution")) if (diagnosticListener.IsEnabled(Diagnostics.BeforeOnActionExecution.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnActionExecution", Diagnostics.BeforeOnActionExecution.EventName,
new new BeforeOnActionExecution(
{ actionExecutingContext.ActionDescriptor,
actionDescriptor = actionExecutingContext.ActionDescriptor, actionExecutingContext,
actionExecutingContext = actionExecutingContext, filter
filter = filter ));
});
} }
} }
@ -554,16 +540,15 @@ namespace Microsoft.AspNetCore.Mvc
private static void AfterOnActionExecutionImpl(DiagnosticListener diagnosticListener, ActionExecutedContext actionExecutedContext, IAsyncActionFilter filter) private static void AfterOnActionExecutionImpl(DiagnosticListener diagnosticListener, ActionExecutedContext actionExecutedContext, IAsyncActionFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnActionExecution")) if (diagnosticListener.IsEnabled(Diagnostics.AfterOnActionExecution.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnActionExecution", Diagnostics.AfterOnActionExecution.EventName,
new new AfterOnActionExecution(
{ actionExecutedContext.ActionDescriptor,
actionDescriptor = actionExecutedContext.ActionDescriptor, actionExecutedContext,
actionExecutedContext = actionExecutedContext, filter
filter = filter ));
});
} }
} }
@ -585,16 +570,15 @@ namespace Microsoft.AspNetCore.Mvc
private static void BeforeOnActionExecutingImpl(DiagnosticListener diagnosticListener, ActionExecutingContext actionExecutingContext, IActionFilter filter) private static void BeforeOnActionExecutingImpl(DiagnosticListener diagnosticListener, ActionExecutingContext actionExecutingContext, IActionFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnActionExecuting")) if (diagnosticListener.IsEnabled(Diagnostics.BeforeOnActionExecuting.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnActionExecuting", Diagnostics.BeforeOnActionExecuting.EventName,
new new BeforeOnActionExecuting(
{ actionExecutingContext.ActionDescriptor,
actionDescriptor = actionExecutingContext.ActionDescriptor, actionExecutingContext,
actionExecutingContext = actionExecutingContext, filter
filter = filter ));
});
} }
} }
@ -616,16 +600,15 @@ namespace Microsoft.AspNetCore.Mvc
private static void AfterOnActionExecutingImpl(DiagnosticListener diagnosticListener, ActionExecutingContext actionExecutingContext, IActionFilter filter) private static void AfterOnActionExecutingImpl(DiagnosticListener diagnosticListener, ActionExecutingContext actionExecutingContext, IActionFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnActionExecuting")) if (diagnosticListener.IsEnabled(Diagnostics.AfterOnActionExecuting.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnActionExecuting", Diagnostics.AfterOnActionExecuting.EventName,
new new AfterOnActionExecuting(
{ actionExecutingContext.ActionDescriptor,
actionDescriptor = actionExecutingContext.ActionDescriptor, actionExecutingContext,
actionExecutingContext = actionExecutingContext, filter
filter = filter ));
});
} }
} }
@ -647,16 +630,15 @@ namespace Microsoft.AspNetCore.Mvc
private static void BeforeOnActionExecutedImpl(DiagnosticListener diagnosticListener, ActionExecutedContext actionExecutedContext, IActionFilter filter) private static void BeforeOnActionExecutedImpl(DiagnosticListener diagnosticListener, ActionExecutedContext actionExecutedContext, IActionFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnActionExecuted")) if (diagnosticListener.IsEnabled(Diagnostics.BeforeOnActionExecuted.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnActionExecuted", Diagnostics.BeforeOnActionExecuted.EventName,
new new BeforeOnActionExecuted(
{ actionExecutedContext.ActionDescriptor,
actionDescriptor = actionExecutedContext.ActionDescriptor, actionExecutedContext,
actionExecutedContext = actionExecutedContext, filter
filter = filter ));
});
} }
} }
@ -678,23 +660,22 @@ namespace Microsoft.AspNetCore.Mvc
private static void AfterOnActionExecutedImpl(DiagnosticListener diagnosticListener, ActionExecutedContext actionExecutedContext, IActionFilter filter) private static void AfterOnActionExecutedImpl(DiagnosticListener diagnosticListener, ActionExecutedContext actionExecutedContext, IActionFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnActionExecuted")) if (diagnosticListener.IsEnabled(Diagnostics.AfterOnActionExecuted.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnActionExecuted", Diagnostics.AfterOnActionExecuted.EventName,
new new AfterOnActionExecuted(
{ actionExecutedContext.ActionDescriptor,
actionDescriptor = actionExecutedContext.ActionDescriptor, actionExecutedContext,
actionExecutedContext = actionExecutedContext, filter
filter = filter ));
});
} }
} }
public static void BeforeActionMethod( public static void BeforeActionMethod(
this DiagnosticListener diagnosticListener, this DiagnosticListener diagnosticListener,
ActionContext actionContext, ActionContext actionContext,
IDictionary<string, object> actionArguments, IReadOnlyDictionary<string, object> actionArguments,
object controller) object controller)
{ {
Debug.Assert(diagnosticListener != null); Debug.Assert(diagnosticListener != null);
@ -709,25 +690,24 @@ namespace Microsoft.AspNetCore.Mvc
} }
} }
private static void BeforeActionMethodImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, IDictionary<string, object> actionArguments, object controller) private static void BeforeActionMethodImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, IReadOnlyDictionary<string, object> actionArguments, object controller)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeActionMethod")) if (diagnosticListener.IsEnabled(Diagnostics.BeforeActionMethod.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeActionMethod", Diagnostics.BeforeActionMethod.EventName,
new new BeforeActionMethod(
{ actionContext,
actionContext = actionContext, actionArguments,
arguments = actionArguments, controller
controller = controller ));
});
} }
} }
public static void AfterActionMethod( public static void AfterActionMethod(
this DiagnosticListener diagnosticListener, this DiagnosticListener diagnosticListener,
ActionContext actionContext, ActionContext actionContext,
IDictionary<string, object> actionArguments, IReadOnlyDictionary<string, object> actionArguments,
object controller, object controller,
IActionResult result) IActionResult result)
{ {
@ -743,19 +723,18 @@ namespace Microsoft.AspNetCore.Mvc
} }
} }
private static void AfterActionMethodImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, IDictionary<string, object> actionArguments, object controller, IActionResult result) private static void AfterActionMethodImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, IReadOnlyDictionary<string, object> actionArguments, object controller, IActionResult result)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterActionMethod")) if (diagnosticListener.IsEnabled(Diagnostics.AfterActionMethod.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterActionMethod", Diagnostics.AfterActionMethod.EventName,
new new AfterActionMethod(
{ actionContext,
actionContext = actionContext, actionArguments,
arguments = actionArguments, controller,
controller = controller, result
result = result ));
});
} }
} }
@ -777,16 +756,15 @@ namespace Microsoft.AspNetCore.Mvc
private static void BeforeOnResultExecutionImpl(DiagnosticListener diagnosticListener, ResultExecutingContext resultExecutingContext, IAsyncResultFilter filter) private static void BeforeOnResultExecutionImpl(DiagnosticListener diagnosticListener, ResultExecutingContext resultExecutingContext, IAsyncResultFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResultExecution")) if (diagnosticListener.IsEnabled(Diagnostics.BeforeOnResultExecution.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnResultExecution", Diagnostics.BeforeOnResultExecution.EventName,
new new BeforeOnResultExecution(
{ resultExecutingContext.ActionDescriptor,
actionDescriptor = resultExecutingContext.ActionDescriptor, resultExecutingContext,
resultExecutingContext = resultExecutingContext, filter
filter = filter ));
});
} }
} }
@ -808,16 +786,15 @@ namespace Microsoft.AspNetCore.Mvc
private static void AfterOnResultExecutionImpl(DiagnosticListener diagnosticListener, ResultExecutedContext resultExecutedContext, IAsyncResultFilter filter) private static void AfterOnResultExecutionImpl(DiagnosticListener diagnosticListener, ResultExecutedContext resultExecutedContext, IAsyncResultFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResultExecution")) if (diagnosticListener.IsEnabled(Diagnostics.AfterOnResultExecution.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnResultExecution", Diagnostics.AfterOnResultExecution.EventName,
new new AfterOnResultExecution(
{ resultExecutedContext.ActionDescriptor,
actionDescriptor = resultExecutedContext.ActionDescriptor, resultExecutedContext,
resultExecutedContext = resultExecutedContext, filter
filter = filter ));
});
} }
} }
@ -839,16 +816,15 @@ namespace Microsoft.AspNetCore.Mvc
private static void BeforeOnResultExecutingImpl(DiagnosticListener diagnosticListener, ResultExecutingContext resultExecutingContext, IResultFilter filter) private static void BeforeOnResultExecutingImpl(DiagnosticListener diagnosticListener, ResultExecutingContext resultExecutingContext, IResultFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResultExecuting")) if (diagnosticListener.IsEnabled(Diagnostics.BeforeOnResultExecuting.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnResultExecuting", Diagnostics.BeforeOnResultExecuting.EventName,
new new BeforeOnResultExecuting(
{ resultExecutingContext.ActionDescriptor,
actionDescriptor = resultExecutingContext.ActionDescriptor, resultExecutingContext,
resultExecutingContext = resultExecutingContext, filter
filter = filter ));
});
} }
} }
@ -870,16 +846,15 @@ namespace Microsoft.AspNetCore.Mvc
private static void AfterOnResultExecutingImpl(DiagnosticListener diagnosticListener, ResultExecutingContext resultExecutingContext, IResultFilter filter) private static void AfterOnResultExecutingImpl(DiagnosticListener diagnosticListener, ResultExecutingContext resultExecutingContext, IResultFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResultExecuting")) if (diagnosticListener.IsEnabled(Diagnostics.AfterOnResultExecuting.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnResultExecuting", Diagnostics.AfterOnResultExecuting.EventName,
new new AfterOnResultExecuting(
{ resultExecutingContext.ActionDescriptor,
actionDescriptor = resultExecutingContext.ActionDescriptor, resultExecutingContext,
resultExecutingContext = resultExecutingContext, filter
filter = filter ));
});
} }
} }
@ -901,16 +876,15 @@ namespace Microsoft.AspNetCore.Mvc
private static void BeforeOnResultExecutedImpl(DiagnosticListener diagnosticListener, ResultExecutedContext resultExecutedContext, IResultFilter filter) private static void BeforeOnResultExecutedImpl(DiagnosticListener diagnosticListener, ResultExecutedContext resultExecutedContext, IResultFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResultExecuted")) if (diagnosticListener.IsEnabled(Diagnostics.BeforeOnResultExecuted.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnResultExecuted", Diagnostics.BeforeOnResultExecuted.EventName,
new new BeforeOnResultExecuted(
{ resultExecutedContext.ActionDescriptor,
actionDescriptor = resultExecutedContext.ActionDescriptor, resultExecutedContext,
resultExecutedContext = resultExecutedContext, filter
filter = filter ));
});
} }
} }
@ -932,16 +906,15 @@ namespace Microsoft.AspNetCore.Mvc
private static void AfterOnResultExecutedImpl(DiagnosticListener diagnosticListener, ResultExecutedContext resultExecutedContext, IResultFilter filter) private static void AfterOnResultExecutedImpl(DiagnosticListener diagnosticListener, ResultExecutedContext resultExecutedContext, IResultFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResultExecuted")) if (diagnosticListener.IsEnabled(Diagnostics.AfterOnResultExecuted.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnResultExecuted", Diagnostics.AfterOnResultExecuted.EventName,
new new AfterOnResultExecuted(
{ resultExecutedContext.ActionDescriptor,
actionDescriptor = resultExecutedContext.ActionDescriptor, resultExecutedContext,
resultExecutedContext = resultExecutedContext, filter
filter = filter ));
});
} }
} }
@ -963,11 +936,11 @@ namespace Microsoft.AspNetCore.Mvc
private static void BeforeActionResultImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, IActionResult result) private static void BeforeActionResultImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, IActionResult result)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeActionResult")) if (diagnosticListener.IsEnabled(Diagnostics.BeforeActionResult.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeActionResult", Diagnostics.BeforeActionResult.EventName,
new { actionContext = actionContext, result = result }); new BeforeActionResult(actionContext, result));
} }
} }
@ -989,11 +962,11 @@ namespace Microsoft.AspNetCore.Mvc
private static void AfterActionResultImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, IActionResult result) private static void AfterActionResultImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, IActionResult result)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterActionResult")) if (diagnosticListener.IsEnabled(Diagnostics.AfterActionResult.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterActionResult", Diagnostics.AfterActionResult.EventName,
new { actionContext = actionContext, result = result }); new AfterActionResult(actionContext, result));
} }
} }
} }

View File

@ -21,6 +21,31 @@ namespace Microsoft.AspNetCore.Mvc.ApplicationParts
System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItem> CompiledItems { get; } System.Collections.Generic.IEnumerable<Microsoft.AspNetCore.Razor.Hosting.RazorCompiledItem> CompiledItems { get; }
} }
} }
namespace Microsoft.AspNetCore.Mvc.Diagnostics
{
public sealed partial class AfterViewPage : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.Razor.AfterViewPage";
public AfterViewPage(Microsoft.AspNetCore.Mvc.Razor.IRazorPage page, Microsoft.AspNetCore.Mvc.Rendering.ViewContext viewContext, Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Http.HttpContext httpContext) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Http.HttpContext HttpContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Razor.IRazorPage Page { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.Rendering.ViewContext ViewContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public sealed partial class BeforeViewPage : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.Razor.BeforeViewPage";
public BeforeViewPage(Microsoft.AspNetCore.Mvc.Razor.IRazorPage page, Microsoft.AspNetCore.Mvc.Rendering.ViewContext viewContext, Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Http.HttpContext httpContext) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Http.HttpContext HttpContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Razor.IRazorPage Page { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.Rendering.ViewContext ViewContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
}
namespace Microsoft.AspNetCore.Mvc.Razor namespace Microsoft.AspNetCore.Mvc.Razor
{ {
public partial class HelperResult : Microsoft.AspNetCore.Html.IHtmlContent public partial class HelperResult : Microsoft.AspNetCore.Html.IHtmlContent

View File

@ -0,0 +1,74 @@
// 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.Collections.Generic;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.AspNetCore.Mvc.Rendering;
namespace Microsoft.AspNetCore.Mvc.Diagnostics
{
public sealed class BeforeViewPage : EventData
{
public const string EventName = EventNamespace +
"Razor." +
nameof(BeforeViewPage);
public BeforeViewPage(IRazorPage page, ViewContext viewContext, ActionDescriptor actionDescriptor, HttpContext httpContext)
{
Page = page;
ViewContext = viewContext;
ActionDescriptor = actionDescriptor;
HttpContext = httpContext;
}
public IRazorPage Page { get; }
public ViewContext ViewContext { get; }
public ActionDescriptor ActionDescriptor { get; }
public HttpContext HttpContext { get; }
protected override int Count => 4;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(Page), Page),
1 => new KeyValuePair<string, object>(nameof(ViewContext), ViewContext),
2 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
3 => new KeyValuePair<string, object>(nameof(HttpContext), HttpContext),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class AfterViewPage : EventData
{
public const string EventName = EventNamespace +
"Razor." +
nameof(AfterViewPage);
public AfterViewPage(IRazorPage page, ViewContext viewContext, ActionDescriptor actionDescriptor, HttpContext httpContext)
{
Page = page;
ViewContext = viewContext;
ActionDescriptor = actionDescriptor;
HttpContext = httpContext;
}
public IRazorPage Page { get; }
public ViewContext ViewContext { get; }
public ActionDescriptor ActionDescriptor { get; }
public HttpContext HttpContext { get; }
protected override int Count => 4;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(Page), Page),
1 => new KeyValuePair<string, object>(nameof(ViewContext), ViewContext),
2 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
3 => new KeyValuePair<string, object>(nameof(HttpContext), HttpContext),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
}

View File

@ -3,10 +3,12 @@
using System.Diagnostics; using System.Diagnostics;
using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.Diagnostics;
using Microsoft.AspNetCore.Http;
namespace Microsoft.AspNetCore.Mvc.Razor namespace Microsoft.AspNetCore.Mvc.Razor
{ {
internal static class MvcRazorDiagnosticSourceExtensions internal static class MvcRazorDiagnosticListenerExtensions
{ {
public static void BeforeViewPage( public static void BeforeViewPage(
this DiagnosticListener diagnosticListener, this DiagnosticListener diagnosticListener,
@ -25,17 +27,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor
IRazorPage page, IRazorPage page,
ViewContext viewContext) ViewContext viewContext)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.Razor.BeforeViewPage")) if (diagnosticListener.IsEnabled(Diagnostics.BeforeViewPage.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.Razor.BeforeViewPage", Diagnostics.BeforeViewPage.EventName,
new new BeforeViewPage(
{ page,
page = page, viewContext,
viewContext = viewContext, viewContext.ActionDescriptor,
actionDescriptor = viewContext.ActionDescriptor, viewContext.HttpContext
httpContext = viewContext.HttpContext, ));
});
} }
} }
@ -56,17 +57,16 @@ namespace Microsoft.AspNetCore.Mvc.Razor
IRazorPage page, IRazorPage page,
ViewContext viewContext) ViewContext viewContext)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.Razor.AfterViewPage")) if (diagnosticListener.IsEnabled(Diagnostics.AfterViewPage.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.Razor.AfterViewPage", Diagnostics.AfterViewPage.EventName,
new new AfterViewPage(
{ page,
page = page, viewContext,
viewContext = viewContext, viewContext.ActionDescriptor,
actionDescriptor = viewContext.ActionDescriptor, viewContext.HttpContext
httpContext = viewContext.HttpContext, ));
});
} }
} }
} }

View File

@ -276,37 +276,12 @@ namespace Microsoft.AspNetCore.Mvc.Razor
public override void BeginContext(int position, int length, bool isLiteral) public override void BeginContext(int position, int length, bool isLiteral)
{ {
const string BeginContextEvent = "Microsoft.AspNetCore.Mvc.Razor.BeginInstrumentationContext"; // noop
if (DiagnosticSource?.IsEnabled(BeginContextEvent) == true)
{
DiagnosticSource.Write(
BeginContextEvent,
new
{
httpContext = Context,
path = Path,
position = position,
length = length,
isLiteral = isLiteral,
});
}
} }
public override void EndContext() public override void EndContext()
{ {
const string EndContextEvent = "Microsoft.AspNetCore.Mvc.Razor.EndInstrumentationContext"; // noop
if (DiagnosticSource?.IsEnabled(EndContextEvent) == true)
{
DiagnosticSource.Write(
EndContextEvent,
new
{
httpContext = Context,
path = Path,
});
}
} }
private void EnsureMethodCanBeInvoked(string methodName) private void EnsureMethodCanBeInvoked(string methodName)

View File

@ -26,7 +26,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
{ {
public RazorPageActivatorTest() public RazorPageActivatorTest()
{ {
DiagnosticSource = new DiagnosticListener("Microsoft.AspNetCore"); DiagnosticListener = new DiagnosticListener("Microsoft.AspNetCore");
HtmlEncoder = new HtmlTestEncoder(); HtmlEncoder = new HtmlTestEncoder();
JsonHelper = Mock.Of<IJsonHelper>(); JsonHelper = Mock.Of<IJsonHelper>();
MetadataProvider = new EmptyModelMetadataProvider(); MetadataProvider = new EmptyModelMetadataProvider();
@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
UrlHelperFactory = new UrlHelperFactory(); UrlHelperFactory = new UrlHelperFactory();
} }
private DiagnosticSource DiagnosticSource { get; } private DiagnosticListener DiagnosticListener { get; }
private HtmlEncoder HtmlEncoder { get; } private HtmlEncoder HtmlEncoder { get; }
@ -62,7 +62,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
activator.Activate(instance, viewContext); activator.Activate(instance, viewContext);
// Assert // Assert
Assert.Same(DiagnosticSource, instance.DiagnosticSource); Assert.Same(DiagnosticListener, instance.DiagnosticSource);
Assert.Same(HtmlEncoder, instance.HtmlEncoder); Assert.Same(HtmlEncoder, instance.HtmlEncoder);
Assert.Same(JsonHelper, instance.Json); Assert.Same(JsonHelper, instance.Json);
Assert.Same(urlHelper, instance.Url); Assert.Same(urlHelper, instance.Url);
@ -97,7 +97,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
activator.Activate(instance, viewContext); activator.Activate(instance, viewContext);
// Assert // Assert
Assert.Same(DiagnosticSource, instance.DiagnosticSource); Assert.Same(DiagnosticListener, instance.DiagnosticSource);
Assert.Same(HtmlEncoder, instance.HtmlEncoder); Assert.Same(HtmlEncoder, instance.HtmlEncoder);
// When we don't have a model property, the activator will just leave ViewData alone. // When we don't have a model property, the activator will just leave ViewData alone.
@ -124,7 +124,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
activator.Activate(instance, viewContext); activator.Activate(instance, viewContext);
// Assert // Assert
Assert.Same(DiagnosticSource, instance.DiagnosticSource); Assert.Same(DiagnosticListener, instance.DiagnosticSource);
Assert.Same(HtmlEncoder, instance.HtmlEncoder); Assert.Same(HtmlEncoder, instance.HtmlEncoder);
Assert.Same(JsonHelper, instance.Json); Assert.Same(JsonHelper, instance.Json);
Assert.Same(urlHelper, instance.Url); Assert.Same(urlHelper, instance.Url);
@ -229,7 +229,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
private RazorPageActivator CreateActivator() private RazorPageActivator CreateActivator()
{ {
return new RazorPageActivator(MetadataProvider, UrlHelperFactory, JsonHelper, DiagnosticSource, HtmlEncoder, ModelExpressionProvider); return new RazorPageActivator(MetadataProvider, UrlHelperFactory, JsonHelper, DiagnosticListener, HtmlEncoder, ModelExpressionProvider);
} }
private ViewContext CreateViewContext(ViewDataDictionary viewData = null) private ViewContext CreateViewContext(ViewDataDictionary viewData = null)

View File

@ -948,216 +948,6 @@ namespace Microsoft.AspNetCore.Mvc.Razor
Assert.Same(HtmlString.Empty, actual); Assert.Same(HtmlString.Empty, actual);
} }
[Fact]
public async Task WriteAttribute_WritesBeginAndEndEvents_ToDiagnosticSource()
{
// Arrange
var path = "path-to-page";
var page = CreatePage(p =>
{
p.HtmlEncoder = new HtmlTestEncoder();
p.BeginWriteAttribute("href", "prefix", 0, "suffix", 34, 2);
p.WriteAttributeValue("prefix", 0, "attr1-value", 8, 14, true);
p.WriteAttributeValue("prefix2", 22, "attr2", 29, 5, false);
p.EndWriteAttribute();
});
page.Path = path;
var adapter = new TestDiagnosticListener();
var diagnosticListener = new DiagnosticListener("Microsoft.AspNetCore.Mvc.Razor");
diagnosticListener.SubscribeWithAdapter(adapter);
page.DiagnosticSource = diagnosticListener;
// Act
await page.ExecuteAsync();
// Assert
Func<object, TestDiagnosticListener.BeginPageInstrumentationData> assertStartEvent = data =>
{
var beginEvent = Assert.IsType<TestDiagnosticListener.BeginPageInstrumentationData>(data);
Assert.NotNull(beginEvent.HttpContext);
Assert.Equal(path, beginEvent.Path);
return beginEvent;
};
Action<object> assertEndEvent = data =>
{
var endEvent = Assert.IsType<TestDiagnosticListener.EndPageInstrumentationData>(data);
Assert.NotNull(endEvent.HttpContext);
Assert.Equal(path, endEvent.Path);
};
Assert.Collection(adapter.PageInstrumentationData,
data =>
{
var beginEvent = assertStartEvent(data);
Assert.Equal(0, beginEvent.Position);
Assert.Equal(6, beginEvent.Length);
Assert.True(beginEvent.IsLiteral);
},
assertEndEvent,
data =>
{
var beginEvent = assertStartEvent(data);
Assert.Equal(0, beginEvent.Position);
Assert.Equal(6, beginEvent.Length);
Assert.True(beginEvent.IsLiteral);
},
assertEndEvent,
data =>
{
var beginEvent = assertStartEvent(data);
Assert.Equal(8, beginEvent.Position);
Assert.Equal(14, beginEvent.Length);
Assert.True(beginEvent.IsLiteral);
},
assertEndEvent,
data =>
{
var beginEvent = assertStartEvent(data);
Assert.Equal(22, beginEvent.Position);
Assert.Equal(7, beginEvent.Length);
Assert.True(beginEvent.IsLiteral);
},
assertEndEvent,
data =>
{
var beginEvent = assertStartEvent(data);
Assert.Equal(29, beginEvent.Position);
Assert.Equal(5, beginEvent.Length);
Assert.False(beginEvent.IsLiteral);
},
assertEndEvent,
data =>
{
var beginEvent = assertStartEvent(data);
Assert.Equal(34, beginEvent.Position);
Assert.Equal(6, beginEvent.Length);
Assert.True(beginEvent.IsLiteral);
},
assertEndEvent);
}
[Fact]
public async Task WriteAttribute_WithBoolValue_WritesBeginAndEndEvents_ToDiagnosticSource()
{
// Arrange
var path = "some-path";
var page = CreatePage(p =>
{
p.HtmlEncoder = new HtmlTestEncoder();
p.BeginWriteAttribute("href", "prefix", 0, "suffix", 10, 1);
p.WriteAttributeValue("", 6, "true", 6, 4, false);
p.EndWriteAttribute();
});
page.Path = path;
var adapter = new TestDiagnosticListener();
var diagnosticListener = new DiagnosticListener("Microsoft.AspNetCore.Mvc.Razor");
diagnosticListener.SubscribeWithAdapter(adapter);
page.DiagnosticSource = diagnosticListener;
// Act
await page.ExecuteAsync();
// Assert
Func<object, TestDiagnosticListener.BeginPageInstrumentationData> assertStartEvent = data =>
{
var beginEvent = Assert.IsType<TestDiagnosticListener.BeginPageInstrumentationData>(data);
Assert.NotNull(beginEvent.HttpContext);
Assert.Equal(path, beginEvent.Path);
return beginEvent;
};
Action<object> assertEndEvent = data =>
{
var endEvent = Assert.IsType<TestDiagnosticListener.EndPageInstrumentationData>(data);
Assert.NotNull(endEvent.HttpContext);
Assert.Equal(path, endEvent.Path);
};
Assert.Collection(adapter.PageInstrumentationData,
data =>
{
var beginEvent = assertStartEvent(data);
Assert.Equal(0, beginEvent.Position);
Assert.Equal(6, beginEvent.Length);
Assert.True(beginEvent.IsLiteral);
},
assertEndEvent,
data =>
{
var beginEvent = assertStartEvent(data);
Assert.Equal(6, beginEvent.Position);
Assert.Equal(4, beginEvent.Length);
Assert.False(beginEvent.IsLiteral);
},
assertEndEvent,
data =>
{
var beginEvent = assertStartEvent(data);
Assert.Equal(10, beginEvent.Position);
Assert.Equal(6, beginEvent.Length);
Assert.True(beginEvent.IsLiteral);
},
assertEndEvent);
}
[Fact]
public async Task WriteAttribute_WritesBeginAndEndEvents_ToDiagnosticSource_OnPrefixAndSuffixValues()
{
// Arrange
var path = "some-path";
var page = CreatePage(p =>
{
p.BeginWriteAttribute("href", "prefix", 0, "tail", 7, 0);
p.EndWriteAttribute();
});
page.Path = path;
var adapter = new TestDiagnosticListener();
var diagnosticListener = new DiagnosticListener("Microsoft.AspNetCore.Mvc.Razor");
diagnosticListener.SubscribeWithAdapter(adapter);
page.DiagnosticSource = diagnosticListener;
// Act
await page.ExecuteAsync();
// Assert
Func<object, TestDiagnosticListener.BeginPageInstrumentationData> assertStartEvent = data =>
{
var beginEvent = Assert.IsType<TestDiagnosticListener.BeginPageInstrumentationData>(data);
Assert.NotNull(beginEvent.HttpContext);
Assert.Equal(path, beginEvent.Path);
return beginEvent;
};
Action<object> assertEndEvent = data =>
{
var endEvent = Assert.IsType<TestDiagnosticListener.EndPageInstrumentationData>(data);
Assert.NotNull(endEvent.HttpContext);
Assert.Equal(path, endEvent.Path);
};
Assert.Collection(adapter.PageInstrumentationData,
data =>
{
var beginEvent = assertStartEvent(data);
Assert.Equal(0, beginEvent.Position);
Assert.Equal(6, beginEvent.Length);
Assert.True(beginEvent.IsLiteral);
},
assertEndEvent,
data =>
{
var beginEvent = assertStartEvent(data);
Assert.Equal(7, beginEvent.Position);
Assert.Equal(4, beginEvent.Length);
Assert.True(beginEvent.IsLiteral);
},
assertEndEvent);
}
public static TheoryData AddHtmlAttributeValues_ValueData public static TheoryData AddHtmlAttributeValues_ValueData
{ {
get get

View File

@ -143,6 +143,132 @@ namespace Microsoft.AspNetCore.Mvc.ApplicationModels
protected virtual bool ShouldApply(Microsoft.AspNetCore.Mvc.ApplicationModels.PageRouteModel action) { throw null; } protected virtual bool ShouldApply(Microsoft.AspNetCore.Mvc.ApplicationModels.PageRouteModel action) { throw null; }
} }
} }
namespace Microsoft.AspNetCore.Mvc.Diagnostics
{
public sealed partial class AfterHandlerMethod : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.AfterHandlerMethod";
public AfterHandlerMethod(Microsoft.AspNetCore.Mvc.ActionContext actionContext, System.Collections.Generic.IReadOnlyDictionary<string, object> arguments, Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.HandlerMethodDescriptor handlerMethodDescriptor, object instance, Microsoft.AspNetCore.Mvc.IActionResult result) { }
public Microsoft.AspNetCore.Mvc.ActionContext ActionContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public System.Collections.Generic.IReadOnlyDictionary<string, object> Arguments { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.HandlerMethodDescriptor HandlerMethodDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public object Instance { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Mvc.IActionResult Result { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public sealed partial class AfterOnPageHandlerExecuted : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecuted";
public AfterOnPageHandlerExecuted(Microsoft.AspNetCore.Mvc.RazorPages.CompiledPageActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.PageHandlerExecutedContext handlerExecutedContext, Microsoft.AspNetCore.Mvc.Filters.IPageFilter filter) { }
public Microsoft.AspNetCore.Mvc.RazorPages.CompiledPageActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IPageFilter Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.PageHandlerExecutedContext HandlerExecutedContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
}
public sealed partial class AfterOnPageHandlerExecuting : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecuting";
public AfterOnPageHandlerExecuting(Microsoft.AspNetCore.Mvc.RazorPages.CompiledPageActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.PageHandlerExecutingContext handlerExecutingContext, Microsoft.AspNetCore.Mvc.Filters.IPageFilter filter) { }
public Microsoft.AspNetCore.Mvc.RazorPages.CompiledPageActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IPageFilter Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.PageHandlerExecutingContext HandlerExecutingContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
}
public sealed partial class AfterOnPageHandlerExecution : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecution";
public AfterOnPageHandlerExecution(Microsoft.AspNetCore.Mvc.RazorPages.CompiledPageActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.PageHandlerExecutedContext handlerExecutedContext, Microsoft.AspNetCore.Mvc.Filters.IAsyncPageFilter filter) { }
public Microsoft.AspNetCore.Mvc.RazorPages.CompiledPageActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IAsyncPageFilter Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.PageHandlerExecutedContext HandlerExecutedContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
}
public sealed partial class AfterOnPageHandlerSelected : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.AfterOnPageHandlerSelected";
public AfterOnPageHandlerSelected(Microsoft.AspNetCore.Mvc.RazorPages.CompiledPageActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.PageHandlerSelectedContext handlerSelectedContext, Microsoft.AspNetCore.Mvc.Filters.IPageFilter filter) { }
public Microsoft.AspNetCore.Mvc.RazorPages.CompiledPageActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IPageFilter Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.PageHandlerSelectedContext HandlerSelectedContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
}
public sealed partial class AfterOnPageHandlerSelection : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.AfterOnPageHandlerSelection";
public AfterOnPageHandlerSelection(Microsoft.AspNetCore.Mvc.RazorPages.CompiledPageActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.PageHandlerSelectedContext handlerSelectedContext, Microsoft.AspNetCore.Mvc.Filters.IAsyncPageFilter filter) { }
public Microsoft.AspNetCore.Mvc.RazorPages.CompiledPageActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IAsyncPageFilter Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.PageHandlerSelectedContext HandlerSelectedContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
}
public sealed partial class BeforeHandlerMethod : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.BeforeHandlerMethod";
public BeforeHandlerMethod(Microsoft.AspNetCore.Mvc.ActionContext actionContext, System.Collections.Generic.IReadOnlyDictionary<string, object> arguments, Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.HandlerMethodDescriptor handlerMethodDescriptor, object instance) { }
public Microsoft.AspNetCore.Mvc.ActionContext ActionContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public System.Collections.Generic.IReadOnlyDictionary<string, object> Arguments { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.HandlerMethodDescriptor HandlerMethodDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public object Instance { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
}
public sealed partial class BeforeOnPageHandlerExecuted : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecuted";
public BeforeOnPageHandlerExecuted(Microsoft.AspNetCore.Mvc.RazorPages.CompiledPageActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.PageHandlerExecutedContext handlerExecutedContext, Microsoft.AspNetCore.Mvc.Filters.IPageFilter filter) { }
public Microsoft.AspNetCore.Mvc.RazorPages.CompiledPageActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IPageFilter Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.PageHandlerExecutedContext HandlerExecutedContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
}
public sealed partial class BeforeOnPageHandlerExecuting : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecuting";
public BeforeOnPageHandlerExecuting(Microsoft.AspNetCore.Mvc.RazorPages.CompiledPageActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.PageHandlerExecutingContext handlerExecutingContext, Microsoft.AspNetCore.Mvc.Filters.IPageFilter filter) { }
public Microsoft.AspNetCore.Mvc.RazorPages.CompiledPageActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IPageFilter Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.PageHandlerExecutingContext HandlerExecutingContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
}
public sealed partial class BeforeOnPageHandlerExecution : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecution";
public BeforeOnPageHandlerExecution(Microsoft.AspNetCore.Mvc.RazorPages.CompiledPageActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.PageHandlerExecutingContext handlerExecutionContext, Microsoft.AspNetCore.Mvc.Filters.IAsyncPageFilter filter) { }
public Microsoft.AspNetCore.Mvc.RazorPages.CompiledPageActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IAsyncPageFilter Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.PageHandlerExecutingContext HandlerExecutionContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
}
public sealed partial class BeforeOnPageHandlerSelected : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerSelected";
public BeforeOnPageHandlerSelected(Microsoft.AspNetCore.Mvc.RazorPages.CompiledPageActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.PageHandlerSelectedContext handlerSelectedContext, Microsoft.AspNetCore.Mvc.Filters.IPageFilter filter) { }
public Microsoft.AspNetCore.Mvc.RazorPages.CompiledPageActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IPageFilter Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.PageHandlerSelectedContext HandlerSelectedContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
}
public sealed partial class BeforeOnPageHandlerSelection : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerSelection";
public BeforeOnPageHandlerSelection(Microsoft.AspNetCore.Mvc.RazorPages.CompiledPageActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.Filters.PageHandlerSelectedContext handlerSelectedContext, Microsoft.AspNetCore.Mvc.Filters.IAsyncPageFilter filter) { }
public Microsoft.AspNetCore.Mvc.RazorPages.CompiledPageActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.IAsyncPageFilter Filter { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.Filters.PageHandlerSelectedContext HandlerSelectedContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
}
}
namespace Microsoft.AspNetCore.Mvc.Filters namespace Microsoft.AspNetCore.Mvc.Filters
{ {
public partial interface IAsyncPageFilter : Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata public partial interface IAsyncPageFilter : Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata

View File

@ -0,0 +1,333 @@
// 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.Collections.Generic;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Http;
namespace Microsoft.AspNetCore.Mvc.Diagnostics
{
public sealed class BeforeHandlerMethod : EventData
{
public const string EventName = EventNamespace + nameof(BeforeHandlerMethod);
public BeforeHandlerMethod(ActionContext actionContext, IReadOnlyDictionary<string, object> arguments, HandlerMethodDescriptor handlerMethodDescriptor, object instance)
{
ActionContext = actionContext;
Arguments = arguments;
HandlerMethodDescriptor = handlerMethodDescriptor;
Instance = instance;
}
public ActionContext ActionContext { get; }
public IReadOnlyDictionary<string, object> Arguments { get; }
public HandlerMethodDescriptor HandlerMethodDescriptor { get; }
public object Instance { get; }
protected override int Count => 4;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionContext), ActionContext),
1 => new KeyValuePair<string, object>(nameof(Arguments), Arguments),
2 => new KeyValuePair<string, object>(nameof(HandlerMethodDescriptor), HandlerMethodDescriptor),
3 => new KeyValuePair<string, object>(nameof(Instance), Instance),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class AfterHandlerMethod : EventData
{
public const string EventName = EventNamespace + nameof(AfterHandlerMethod);
public AfterHandlerMethod(ActionContext actionContext, IReadOnlyDictionary<string, object> arguments, HandlerMethodDescriptor handlerMethodDescriptor, object instance, IActionResult result)
{
ActionContext = actionContext;
Arguments = arguments;
HandlerMethodDescriptor = handlerMethodDescriptor;
Instance = instance;
Result = result;
}
public ActionContext ActionContext { get; }
public IReadOnlyDictionary<string, object> Arguments { get; }
public HandlerMethodDescriptor HandlerMethodDescriptor { get; }
public object Instance { get; }
public IActionResult Result { get; }
protected override int Count => 5;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionContext), ActionContext),
1 => new KeyValuePair<string, object>(nameof(Arguments), Arguments),
2 => new KeyValuePair<string, object>(nameof(HandlerMethodDescriptor), HandlerMethodDescriptor),
3 => new KeyValuePair<string, object>(nameof(Instance), Instance),
4 => new KeyValuePair<string, object>(nameof(Result), Result),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class BeforeOnPageHandlerExecution : EventData
{
public const string EventName = EventNamespace + nameof(BeforeOnPageHandlerExecution);
public BeforeOnPageHandlerExecution(CompiledPageActionDescriptor actionDescriptor, PageHandlerExecutingContext handlerExecutionContext, IAsyncPageFilter filter)
{
ActionDescriptor = actionDescriptor;
HandlerExecutionContext = handlerExecutionContext;
Filter = filter;
}
public CompiledPageActionDescriptor ActionDescriptor { get; }
public PageHandlerExecutingContext HandlerExecutionContext { get; }
public IAsyncPageFilter Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(HandlerExecutionContext), HandlerExecutionContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class AfterOnPageHandlerExecution : EventData
{
public const string EventName = EventNamespace + nameof(AfterOnPageHandlerExecution);
public AfterOnPageHandlerExecution(CompiledPageActionDescriptor actionDescriptor, PageHandlerExecutedContext handlerExecutedContext, IAsyncPageFilter filter)
{
ActionDescriptor = actionDescriptor;
HandlerExecutedContext = handlerExecutedContext;
Filter = filter;
}
public CompiledPageActionDescriptor ActionDescriptor { get; }
public PageHandlerExecutedContext HandlerExecutedContext { get; }
public IAsyncPageFilter Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(HandlerExecutedContext), HandlerExecutedContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class BeforeOnPageHandlerExecuting : EventData
{
public const string EventName = EventNamespace + nameof(BeforeOnPageHandlerExecuting);
public BeforeOnPageHandlerExecuting(CompiledPageActionDescriptor actionDescriptor, PageHandlerExecutingContext handlerExecutingContext, IPageFilter filter)
{
ActionDescriptor = actionDescriptor;
HandlerExecutingContext = handlerExecutingContext;
Filter = filter;
}
public CompiledPageActionDescriptor ActionDescriptor { get; }
public PageHandlerExecutingContext HandlerExecutingContext { get; }
public IPageFilter Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(HandlerExecutingContext), HandlerExecutingContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class AfterOnPageHandlerExecuting : EventData
{
public const string EventName = EventNamespace + nameof(AfterOnPageHandlerExecuting);
public AfterOnPageHandlerExecuting(CompiledPageActionDescriptor actionDescriptor, PageHandlerExecutingContext handlerExecutingContext, IPageFilter filter)
{
ActionDescriptor = actionDescriptor;
HandlerExecutingContext = handlerExecutingContext;
Filter = filter;
}
public CompiledPageActionDescriptor ActionDescriptor { get; }
public PageHandlerExecutingContext HandlerExecutingContext { get; }
public IPageFilter Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(HandlerExecutingContext), HandlerExecutingContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class BeforeOnPageHandlerExecuted : EventData
{
public const string EventName = EventNamespace + nameof(BeforeOnPageHandlerExecuted);
public BeforeOnPageHandlerExecuted(CompiledPageActionDescriptor actionDescriptor, PageHandlerExecutedContext handlerExecutedContext, IPageFilter filter)
{
ActionDescriptor = actionDescriptor;
HandlerExecutedContext = handlerExecutedContext;
Filter = filter;
}
public CompiledPageActionDescriptor ActionDescriptor { get; }
public PageHandlerExecutedContext HandlerExecutedContext { get; }
public IPageFilter Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(HandlerExecutedContext), HandlerExecutedContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class AfterOnPageHandlerExecuted : EventData
{
public const string EventName = EventNamespace + nameof(AfterOnPageHandlerExecuted);
public AfterOnPageHandlerExecuted(CompiledPageActionDescriptor actionDescriptor, PageHandlerExecutedContext handlerExecutedContext, IPageFilter filter)
{
ActionDescriptor = actionDescriptor;
HandlerExecutedContext = handlerExecutedContext;
Filter = filter;
}
public CompiledPageActionDescriptor ActionDescriptor { get; }
public PageHandlerExecutedContext HandlerExecutedContext { get; }
public IPageFilter Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(HandlerExecutedContext), HandlerExecutedContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class BeforeOnPageHandlerSelection : EventData
{
public const string EventName = EventNamespace + nameof(BeforeOnPageHandlerSelection);
public BeforeOnPageHandlerSelection(CompiledPageActionDescriptor actionDescriptor, PageHandlerSelectedContext handlerSelectedContext, IAsyncPageFilter filter)
{
ActionDescriptor = actionDescriptor;
HandlerSelectedContext = handlerSelectedContext;
Filter = filter;
}
public CompiledPageActionDescriptor ActionDescriptor { get; }
public PageHandlerSelectedContext HandlerSelectedContext { get; }
public IAsyncPageFilter Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(HandlerSelectedContext), HandlerSelectedContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class AfterOnPageHandlerSelection : EventData
{
public const string EventName = EventNamespace + nameof(AfterOnPageHandlerSelection);
public AfterOnPageHandlerSelection(CompiledPageActionDescriptor actionDescriptor, PageHandlerSelectedContext handlerSelectedContext, IAsyncPageFilter filter)
{
ActionDescriptor = actionDescriptor;
HandlerSelectedContext = handlerSelectedContext;
Filter = filter;
}
public CompiledPageActionDescriptor ActionDescriptor { get; }
public PageHandlerSelectedContext HandlerSelectedContext { get; }
public IAsyncPageFilter Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(HandlerSelectedContext), HandlerSelectedContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class BeforeOnPageHandlerSelected : EventData
{
public const string EventName = EventNamespace + nameof(BeforeOnPageHandlerSelected);
public BeforeOnPageHandlerSelected(CompiledPageActionDescriptor actionDescriptor, PageHandlerSelectedContext handlerSelectedContext, IPageFilter filter)
{
ActionDescriptor = actionDescriptor;
HandlerSelectedContext = handlerSelectedContext;
Filter = filter;
}
public CompiledPageActionDescriptor ActionDescriptor { get; }
public PageHandlerSelectedContext HandlerSelectedContext { get; }
public IPageFilter Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(HandlerSelectedContext), HandlerSelectedContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class AfterOnPageHandlerSelected : EventData
{
public const string EventName = EventNamespace + nameof(AfterOnPageHandlerSelected);
public AfterOnPageHandlerSelected(CompiledPageActionDescriptor actionDescriptor, PageHandlerSelectedContext handlerSelectedContext, IPageFilter filter)
{
ActionDescriptor = actionDescriptor;
HandlerSelectedContext = handlerSelectedContext;
Filter = filter;
}
public CompiledPageActionDescriptor ActionDescriptor { get; }
public PageHandlerSelectedContext HandlerSelectedContext { get; }
public IPageFilter Filter { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(HandlerSelectedContext), HandlerSelectedContext),
2 => new KeyValuePair<string, object>(nameof(Filter), Filter),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
}

View File

@ -5,16 +5,17 @@ using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure; using Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure;
using Microsoft.AspNetCore.Mvc.Diagnostics;
namespace Microsoft.AspNetCore.Mvc.RazorPages namespace Microsoft.AspNetCore.Mvc.RazorPages
{ {
internal static class MvcRazorPagesDiagnosticSourceExtensions internal static class MvcRazorPagesDiagnosticListenerExtensions
{ {
public static void BeforeHandlerMethod( public static void BeforeHandlerMethod(
this DiagnosticListener diagnosticListener, this DiagnosticListener diagnosticListener,
ActionContext actionContext, ActionContext actionContext,
HandlerMethodDescriptor handlerMethodDescriptor, HandlerMethodDescriptor handlerMethodDescriptor,
IDictionary<string, object> arguments, IReadOnlyDictionary<string, object> arguments,
object instance) object instance)
{ {
Debug.Assert(diagnosticListener != null); Debug.Assert(diagnosticListener != null);
@ -30,19 +31,18 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
} }
} }
private static void BeforeHandlerMethodImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, HandlerMethodDescriptor handlerMethodDescriptor, IDictionary<string, object> arguments, object instance) private static void BeforeHandlerMethodImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, HandlerMethodDescriptor handlerMethodDescriptor, IReadOnlyDictionary<string, object> arguments, object instance)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeHandlerMethod")) if (diagnosticListener.IsEnabled(Diagnostics.BeforeHandlerMethod.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeHandlerMethod", Diagnostics.BeforeHandlerMethod.EventName,
new new BeforeHandlerMethod(
{ actionContext,
actionContext = actionContext, arguments,
arguments = arguments, handlerMethodDescriptor,
handlerMethodDescriptor = handlerMethodDescriptor, instance
instance = instance, ));
});
} }
} }
@ -50,7 +50,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
this DiagnosticListener diagnosticListener, this DiagnosticListener diagnosticListener,
ActionContext actionContext, ActionContext actionContext,
HandlerMethodDescriptor handlerMethodDescriptor, HandlerMethodDescriptor handlerMethodDescriptor,
IDictionary<string, object> arguments, IReadOnlyDictionary<string, object> arguments,
object instance, object instance,
IActionResult result) IActionResult result)
{ {
@ -67,20 +67,19 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
} }
} }
private static void AfterHandlerMethodImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, HandlerMethodDescriptor handlerMethodDescriptor, IDictionary<string, object> arguments, object instance, IActionResult result) private static void AfterHandlerMethodImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, HandlerMethodDescriptor handlerMethodDescriptor, IReadOnlyDictionary<string, object> arguments, object instance, IActionResult result)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterHandlerMethod")) if (diagnosticListener.IsEnabled(Diagnostics.AfterHandlerMethod.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterHandlerMethod", Diagnostics.AfterHandlerMethod.EventName,
new new AfterHandlerMethod(
{ actionContext,
actionContext = actionContext, arguments,
arguments = arguments, handlerMethodDescriptor,
handlerMethodDescriptor = handlerMethodDescriptor, instance,
instance = instance, result
result = result ));
});
} }
} }
@ -102,16 +101,15 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
private static void BeforeOnPageHandlerExecutionImpl(DiagnosticListener diagnosticListener, PageHandlerExecutingContext handlerExecutionContext, IAsyncPageFilter filter) private static void BeforeOnPageHandlerExecutionImpl(DiagnosticListener diagnosticListener, PageHandlerExecutingContext handlerExecutionContext, IAsyncPageFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecution")) if (diagnosticListener.IsEnabled(Diagnostics.BeforeOnPageHandlerExecution.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecution", Diagnostics.BeforeOnPageHandlerExecution.EventName,
new new BeforeOnPageHandlerExecution(
{ handlerExecutionContext.ActionDescriptor,
actionDescriptor = handlerExecutionContext.ActionDescriptor, handlerExecutionContext,
handlerExecutionContext = handlerExecutionContext, filter
filter = filter ));
});
} }
} }
@ -133,16 +131,15 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
private static void AfterOnPageHandlerExecutionImpl(DiagnosticListener diagnosticListener, PageHandlerExecutedContext handlerExecutedContext, IAsyncPageFilter filter) private static void AfterOnPageHandlerExecutionImpl(DiagnosticListener diagnosticListener, PageHandlerExecutedContext handlerExecutedContext, IAsyncPageFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecution")) if (diagnosticListener.IsEnabled(Diagnostics.AfterOnPageHandlerExecution.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecution", Diagnostics.AfterOnPageHandlerExecution.EventName,
new new AfterOnPageHandlerExecution(
{ handlerExecutedContext.ActionDescriptor,
actionDescriptor = handlerExecutedContext.ActionDescriptor, handlerExecutedContext,
handlerExecutedContext = handlerExecutedContext, filter
filter = filter ));
});
} }
} }
@ -164,16 +161,15 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
private static void BeforeOnPageHandlerExecutingImpl(DiagnosticListener diagnosticListener, PageHandlerExecutingContext handlerExecutingContext, IPageFilter filter) private static void BeforeOnPageHandlerExecutingImpl(DiagnosticListener diagnosticListener, PageHandlerExecutingContext handlerExecutingContext, IPageFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecuting")) if (diagnosticListener.IsEnabled(Diagnostics.BeforeOnPageHandlerExecuting.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecuting", Diagnostics.BeforeOnPageHandlerExecuting.EventName,
new new BeforeOnPageHandlerExecuting(
{ handlerExecutingContext.ActionDescriptor,
actionDescriptor = handlerExecutingContext.ActionDescriptor, handlerExecutingContext,
handlerExecutingContext = handlerExecutingContext, filter
filter = filter ));
});
} }
} }
@ -195,16 +191,15 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
private static void AfterOnPageHandlerExecutingImpl(DiagnosticListener diagnosticListener, PageHandlerExecutingContext handlerExecutingContext, IPageFilter filter) private static void AfterOnPageHandlerExecutingImpl(DiagnosticListener diagnosticListener, PageHandlerExecutingContext handlerExecutingContext, IPageFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecuting")) if (diagnosticListener.IsEnabled(Diagnostics.AfterOnPageHandlerExecuting.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecuting", Diagnostics.AfterOnPageHandlerExecuting.EventName,
new new AfterOnPageHandlerExecuting(
{ handlerExecutingContext.ActionDescriptor,
actionDescriptor = handlerExecutingContext.ActionDescriptor, handlerExecutingContext,
handlerExecutingContext = handlerExecutingContext, filter
filter = filter ));
});
} }
} }
@ -226,16 +221,15 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
private static void BeforeOnPageHandlerExecutedImpl(DiagnosticListener diagnosticListener, PageHandlerExecutedContext handlerExecutedContext, IPageFilter filter) private static void BeforeOnPageHandlerExecutedImpl(DiagnosticListener diagnosticListener, PageHandlerExecutedContext handlerExecutedContext, IPageFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecuted")) if (diagnosticListener.IsEnabled(Diagnostics.BeforeOnPageHandlerExecuted.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecuted", Diagnostics.BeforeOnPageHandlerExecuted.EventName,
new new BeforeOnPageHandlerExecuted(
{ handlerExecutedContext.ActionDescriptor,
actionDescriptor = handlerExecutedContext.ActionDescriptor, handlerExecutedContext,
handlerExecutedContext = handlerExecutedContext, filter
filter = filter ));
});
} }
} }
@ -257,16 +251,15 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
private static void AfterOnPageHandlerExecutedImpl(DiagnosticListener diagnosticListener, PageHandlerExecutedContext handlerExecutedContext, IPageFilter filter) private static void AfterOnPageHandlerExecutedImpl(DiagnosticListener diagnosticListener, PageHandlerExecutedContext handlerExecutedContext, IPageFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecuted")) if (diagnosticListener.IsEnabled(Diagnostics.AfterOnPageHandlerExecuted.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecuted", Diagnostics.AfterOnPageHandlerExecuted.EventName,
new new AfterOnPageHandlerExecuted(
{ handlerExecutedContext.ActionDescriptor,
actionDescriptor = handlerExecutedContext.ActionDescriptor, handlerExecutedContext,
handlerExecutedContext = handlerExecutedContext, filter
filter = filter ));
});
} }
} }
@ -288,16 +281,15 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
private static void BeforeOnPageHandlerSelectionImpl(DiagnosticListener diagnosticListener, PageHandlerSelectedContext handlerSelectedContext, IAsyncPageFilter filter) private static void BeforeOnPageHandlerSelectionImpl(DiagnosticListener diagnosticListener, PageHandlerSelectedContext handlerSelectedContext, IAsyncPageFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerSelection")) if (diagnosticListener.IsEnabled(Diagnostics.BeforeOnPageHandlerSelection.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerSelection", Diagnostics.BeforeOnPageHandlerSelection.EventName,
new new BeforeOnPageHandlerSelection(
{ handlerSelectedContext.ActionDescriptor,
actionDescriptor = handlerSelectedContext.ActionDescriptor, handlerSelectedContext,
handlerSelectedContext = handlerSelectedContext, filter
filter = filter ));
});
} }
} }
@ -319,16 +311,15 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
private static void AfterOnPageHandlerSelectionImpl(DiagnosticListener diagnosticListener, PageHandlerSelectedContext handlerSelectedContext, IAsyncPageFilter filter) private static void AfterOnPageHandlerSelectionImpl(DiagnosticListener diagnosticListener, PageHandlerSelectedContext handlerSelectedContext, IAsyncPageFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerSelection")) if (diagnosticListener.IsEnabled(Diagnostics.AfterOnPageHandlerSelection.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnPageHandlerSelection", Diagnostics.AfterOnPageHandlerSelection.EventName,
new new AfterOnPageHandlerSelection(
{ handlerSelectedContext.ActionDescriptor,
actionDescriptor = handlerSelectedContext.ActionDescriptor, handlerSelectedContext,
handlerSelectedContext = handlerSelectedContext, filter
filter = filter ));
});
} }
} }
@ -350,16 +341,15 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
private static void BeforeOnPageHandlerSelectedImpl(DiagnosticListener diagnosticListener, PageHandlerSelectedContext handlerSelectedContext, IPageFilter filter) private static void BeforeOnPageHandlerSelectedImpl(DiagnosticListener diagnosticListener, PageHandlerSelectedContext handlerSelectedContext, IPageFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerSelected")) if (diagnosticListener.IsEnabled(Diagnostics.BeforeOnPageHandlerSelected.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerSelected", Diagnostics.BeforeOnPageHandlerSelected.EventName,
new new BeforeOnPageHandlerSelected(
{ handlerSelectedContext.ActionDescriptor,
actionDescriptor = handlerSelectedContext.ActionDescriptor, handlerSelectedContext,
handlerSelectedContext = handlerSelectedContext, filter
filter = filter ));
});
} }
} }
@ -381,16 +371,15 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
private static void AfterOnPageHandlerSelectedImpl(DiagnosticListener diagnosticListener, PageHandlerSelectedContext handlerSelectedContext, IPageFilter filter) private static void AfterOnPageHandlerSelectedImpl(DiagnosticListener diagnosticListener, PageHandlerSelectedContext handlerSelectedContext, IPageFilter filter)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerSelected")) if (diagnosticListener.IsEnabled(Diagnostics.AfterOnPageHandlerSelected.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterOnPageHandlerSelected", Diagnostics.AfterOnPageHandlerSelected.EventName,
new new AfterOnPageHandlerSelected(
{ handlerSelectedContext.ActionDescriptor,
actionDescriptor = handlerSelectedContext.ActionDescriptor, handlerSelectedContext,
handlerSelectedContext = handlerSelectedContext, filter
filter = filter ));
});
} }
} }
} }

View File

@ -110,38 +110,13 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
/// <inheritdoc /> /// <inheritdoc />
public override void BeginContext(int position, int length, bool isLiteral) public override void BeginContext(int position, int length, bool isLiteral)
{ {
const string BeginContextEvent = "Microsoft.AspNetCore.Mvc.Razor.BeginInstrumentationContext"; // noop
if (DiagnosticSource?.IsEnabled(BeginContextEvent) == true)
{
DiagnosticSource.Write(
BeginContextEvent,
new
{
httpContext = ViewContext,
path = Path,
position = position,
length = length,
isLiteral = isLiteral,
});
}
} }
/// <inheritdoc /> /// <inheritdoc />
public override void EndContext() public override void EndContext()
{ {
const string EndContextEvent = "Microsoft.AspNetCore.Mvc.Razor.EndInstrumentationContext"; // noop
if (DiagnosticSource?.IsEnabled(EndContextEvent) == true)
{
DiagnosticSource.Write(
EndContextEvent,
new
{
httpContext = ViewContext,
path = Path,
});
}
} }
/// <summary> /// <summary>

View File

@ -213,6 +213,92 @@ namespace Microsoft.AspNetCore.Mvc
public override System.Threading.Tasks.Task ExecuteResultAsync(Microsoft.AspNetCore.Mvc.ActionContext context) { throw null; } public override System.Threading.Tasks.Task ExecuteResultAsync(Microsoft.AspNetCore.Mvc.ActionContext context) { throw null; }
} }
} }
namespace Microsoft.AspNetCore.Mvc.Diagnostics
{
public sealed partial class AfterView : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.AfterView";
public AfterView(Microsoft.AspNetCore.Mvc.ViewEngines.IView view, Microsoft.AspNetCore.Mvc.Rendering.ViewContext viewContext) { }
protected override int Count { get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Mvc.ViewEngines.IView View { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.Rendering.ViewContext ViewContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public sealed partial class AfterViewComponent : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.AfterViewComponent";
public AfterViewComponent(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.ViewComponents.ViewComponentContext viewComponentContext, Microsoft.AspNetCore.Mvc.IViewComponentResult viewComponentResult, object viewComponent) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public object ViewComponent { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.ViewComponents.ViewComponentContext ViewComponentContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.IViewComponentResult ViewComponentResult { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public sealed partial class BeforeView : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.BeforeView";
public BeforeView(Microsoft.AspNetCore.Mvc.ViewEngines.IView view, Microsoft.AspNetCore.Mvc.Rendering.ViewContext viewContext) { }
protected override int Count { get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Mvc.ViewEngines.IView View { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.Rendering.ViewContext ViewContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public sealed partial class BeforeViewComponent : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.BeforeViewComponent";
public BeforeViewComponent(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.ViewComponents.ViewComponentContext viewComponentContext, object viewComponent) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public object ViewComponent { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.ViewComponents.ViewComponentContext ViewComponentContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public sealed partial class ViewComponentAfterViewExecute : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.ViewComponentAfterViewExecute";
public ViewComponentAfterViewExecute(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.ViewComponents.ViewComponentContext viewComponentContext, Microsoft.AspNetCore.Mvc.ViewEngines.IView view) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Mvc.ViewEngines.IView View { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.ViewComponents.ViewComponentContext ViewComponentContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public sealed partial class ViewComponentBeforeViewExecute : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.ViewComponentBeforeViewExecute";
public ViewComponentBeforeViewExecute(Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor actionDescriptor, Microsoft.AspNetCore.Mvc.ViewComponents.ViewComponentContext viewComponentContext, Microsoft.AspNetCore.Mvc.ViewEngines.IView view) { }
public Microsoft.AspNetCore.Mvc.Abstractions.ActionDescriptor ActionDescriptor { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Mvc.ViewEngines.IView View { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.ViewComponents.ViewComponentContext ViewComponentContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public sealed partial class ViewFound : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.ViewFound";
public ViewFound(Microsoft.AspNetCore.Mvc.ActionContext actionContext, bool isMainPage, Microsoft.AspNetCore.Mvc.ActionResult result, string viewName, Microsoft.AspNetCore.Mvc.ViewEngines.IView view) { }
public Microsoft.AspNetCore.Mvc.ActionContext ActionContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public bool IsMainPage { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Mvc.ActionResult Result { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public Microsoft.AspNetCore.Mvc.ViewEngines.IView View { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public string ViewName { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
public sealed partial class ViewNotFound : Microsoft.AspNetCore.Mvc.Diagnostics.EventData
{
public const string EventName = "Microsoft.AspNetCore.Mvc.ViewNotFound";
public ViewNotFound(Microsoft.AspNetCore.Mvc.ActionContext actionContext, bool isMainPage, Microsoft.AspNetCore.Mvc.ActionResult result, string viewName, System.Collections.Generic.IEnumerable<string> searchedLocations) { }
public Microsoft.AspNetCore.Mvc.ActionContext ActionContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override int Count { get { throw null; } }
public bool IsMainPage { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected override System.Collections.Generic.KeyValuePair<string, object> this[int index] { get { throw null; } }
public Microsoft.AspNetCore.Mvc.ActionResult Result { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public System.Collections.Generic.IEnumerable<string> SearchedLocations { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public string ViewName { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
}
}
namespace Microsoft.AspNetCore.Mvc.ModelBinding namespace Microsoft.AspNetCore.Mvc.ModelBinding
{ {
public static partial class ModelStateDictionaryExtensions public static partial class ModelStateDictionaryExtensions
@ -1286,7 +1372,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
public static readonly string DefaultContentType; public static readonly string DefaultContentType;
protected ViewExecutor(Microsoft.AspNetCore.Mvc.Infrastructure.IHttpResponseStreamWriterFactory writerFactory, Microsoft.AspNetCore.Mvc.ViewEngines.ICompositeViewEngine viewEngine, System.Diagnostics.DiagnosticListener diagnosticListener) { } protected ViewExecutor(Microsoft.AspNetCore.Mvc.Infrastructure.IHttpResponseStreamWriterFactory writerFactory, Microsoft.AspNetCore.Mvc.ViewEngines.ICompositeViewEngine viewEngine, System.Diagnostics.DiagnosticListener diagnosticListener) { }
public ViewExecutor(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Mvc.MvcViewOptions> viewOptions, Microsoft.AspNetCore.Mvc.Infrastructure.IHttpResponseStreamWriterFactory writerFactory, Microsoft.AspNetCore.Mvc.ViewEngines.ICompositeViewEngine viewEngine, Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory tempDataFactory, System.Diagnostics.DiagnosticListener diagnosticListener, Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider modelMetadataProvider) { } public ViewExecutor(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Mvc.MvcViewOptions> viewOptions, Microsoft.AspNetCore.Mvc.Infrastructure.IHttpResponseStreamWriterFactory writerFactory, Microsoft.AspNetCore.Mvc.ViewEngines.ICompositeViewEngine viewEngine, Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory tempDataFactory, System.Diagnostics.DiagnosticListener diagnosticListener, Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider modelMetadataProvider) { }
protected System.Diagnostics.DiagnosticListener DiagnosticSource { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } } protected System.Diagnostics.DiagnosticListener DiagnosticListener { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider ModelMetadataProvider { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } } protected Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider ModelMetadataProvider { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory TempDataFactory { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } } protected Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory TempDataFactory { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
protected Microsoft.AspNetCore.Mvc.ViewEngines.IViewEngine ViewEngine { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } } protected Microsoft.AspNetCore.Mvc.ViewEngines.IViewEngine ViewEngine { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }

View File

@ -0,0 +1,228 @@
// 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.Collections.Generic;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewComponents;
using Microsoft.AspNetCore.Mvc.ViewEngines;
namespace Microsoft.AspNetCore.Mvc.Diagnostics
{
public sealed class BeforeViewComponent : EventData
{
public const string EventName = EventNamespace + nameof(BeforeViewComponent);
public BeforeViewComponent(ActionDescriptor actionDescriptor, ViewComponentContext viewComponentContext, object viewComponent)
{
ActionDescriptor = actionDescriptor;
ViewComponentContext = viewComponentContext;
ViewComponent = viewComponent;
}
public ActionDescriptor ActionDescriptor { get; }
public ViewComponentContext ViewComponentContext { get; }
public object ViewComponent { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(ViewComponentContext), ViewComponentContext),
2 => new KeyValuePair<string, object>(nameof(ViewComponent), ViewComponent),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class AfterViewComponent : EventData
{
public const string EventName = EventNamespace + nameof(AfterViewComponent);
public AfterViewComponent(ActionDescriptor actionDescriptor, ViewComponentContext viewComponentContext, IViewComponentResult viewComponentResult, object viewComponent)
{
ActionDescriptor = actionDescriptor;
ViewComponentContext = viewComponentContext;
ViewComponentResult = viewComponentResult;
ViewComponent = viewComponent;
}
public ActionDescriptor ActionDescriptor { get; }
public ViewComponentContext ViewComponentContext { get; }
public IViewComponentResult ViewComponentResult { get; }
public object ViewComponent { get; }
protected override int Count => 4;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(ViewComponentContext), ViewComponentContext),
2 => new KeyValuePair<string, object>(nameof(ViewComponent), ViewComponent),
3 => new KeyValuePair<string, object>(nameof(ViewComponentResult), ViewComponentResult),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class ViewComponentBeforeViewExecute : EventData
{
public const string EventName = EventNamespace + nameof(ViewComponentBeforeViewExecute);
public ViewComponentBeforeViewExecute(ActionDescriptor actionDescriptor, ViewComponentContext viewComponentContext, IView view)
{
ActionDescriptor = actionDescriptor;
ViewComponentContext = viewComponentContext;
View = view;
}
public ActionDescriptor ActionDescriptor { get; }
public ViewComponentContext ViewComponentContext { get; }
public IView View { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(ViewComponentContext), ViewComponentContext),
2 => new KeyValuePair<string, object>(nameof(View), View),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class ViewComponentAfterViewExecute : EventData
{
public const string EventName = EventNamespace + nameof(ViewComponentAfterViewExecute);
public ViewComponentAfterViewExecute(ActionDescriptor actionDescriptor, ViewComponentContext viewComponentContext, IView view)
{
ActionDescriptor = actionDescriptor;
ViewComponentContext = viewComponentContext;
View = view;
}
public ActionDescriptor ActionDescriptor { get; }
public ViewComponentContext ViewComponentContext { get; }
public IView View { get; }
protected override int Count => 3;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionDescriptor), ActionDescriptor),
1 => new KeyValuePair<string, object>(nameof(ViewComponentContext), ViewComponentContext),
2 => new KeyValuePair<string, object>(nameof(View), View),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class BeforeView : EventData
{
public const string EventName = EventNamespace + nameof(BeforeView);
public BeforeView(IView view, ViewContext viewContext)
{
View = view;
ViewContext = viewContext;
}
public IView View { get; }
public ViewContext ViewContext { get; }
protected override int Count => 2;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(View), View),
1 => new KeyValuePair<string, object>(nameof(ViewContext), ViewContext),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class AfterView : EventData
{
public const string EventName = EventNamespace + nameof(AfterView);
public AfterView(IView view, ViewContext viewContext)
{
View = view;
ViewContext = viewContext;
}
public IView View { get; }
public ViewContext ViewContext { get; }
protected override int Count => 2;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(View), View),
1 => new KeyValuePair<string, object>(nameof(ViewContext), ViewContext),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class ViewFound : EventData
{
public const string EventName = EventNamespace + nameof(ViewFound);
public ViewFound(ActionContext actionContext, bool isMainPage, ActionResult result, string viewName, IView view)
{
ActionContext = actionContext;
IsMainPage = isMainPage;
Result = result;
ViewName = viewName;
View = view;
}
public ActionContext ActionContext { get; }
public bool IsMainPage { get; }
public ActionResult Result { get; }
public string ViewName { get; }
public IView View { get; }
protected override int Count => 5;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionContext), ActionContext),
1 => new KeyValuePair<string, object>(nameof(IsMainPage), IsMainPage),
2 => new KeyValuePair<string, object>(nameof(Result), Result),
3 => new KeyValuePair<string, object>(nameof(ViewName), ViewName),
4 => new KeyValuePair<string, object>(nameof(View), View),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
public sealed class ViewNotFound : EventData
{
public const string EventName = EventNamespace + nameof(ViewNotFound);
public ViewNotFound(ActionContext actionContext, bool isMainPage, ActionResult result, string viewName, IEnumerable<string> searchedLocations)
{
ActionContext = actionContext;
IsMainPage = isMainPage;
Result = result;
ViewName = viewName;
SearchedLocations = searchedLocations;
}
public ActionContext ActionContext { get; }
public bool IsMainPage { get; }
public ActionResult Result { get; }
public string ViewName { get; }
public IEnumerable<string> SearchedLocations { get; }
protected override int Count => 5;
protected override KeyValuePair<string, object> this[int index] => index switch
{
0 => new KeyValuePair<string, object>(nameof(ActionContext), ActionContext),
1 => new KeyValuePair<string, object>(nameof(IsMainPage), IsMainPage),
2 => new KeyValuePair<string, object>(nameof(Result), Result),
3 => new KeyValuePair<string, object>(nameof(ViewName), ViewName),
4 => new KeyValuePair<string, object>(nameof(SearchedLocations), SearchedLocations),
_ => throw new IndexOutOfRangeException(nameof(index))
};
}
}

View File

@ -6,10 +6,11 @@ using System.Diagnostics;
using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewComponents; using Microsoft.AspNetCore.Mvc.ViewComponents;
using Microsoft.AspNetCore.Mvc.ViewEngines; using Microsoft.AspNetCore.Mvc.ViewEngines;
using Microsoft.AspNetCore.Mvc.Diagnostics;
namespace Microsoft.AspNetCore.Mvc.ViewFeatures namespace Microsoft.AspNetCore.Mvc.ViewFeatures
{ {
internal static class MvcViewFeaturesDiagnosticSourceExtensions internal static class MvcViewFeaturesDiagnosticListenerExtensions
{ {
public static void BeforeViewComponent( public static void BeforeViewComponent(
this DiagnosticListener diagnosticListener, this DiagnosticListener diagnosticListener,
@ -25,16 +26,15 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
private static void BeforeViewComponentImpl(DiagnosticListener diagnosticListener, ViewComponentContext context, object viewComponent) private static void BeforeViewComponentImpl(DiagnosticListener diagnosticListener, ViewComponentContext context, object viewComponent)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeViewComponent")) if (diagnosticListener.IsEnabled(Diagnostics.BeforeViewComponent.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeViewComponent", Diagnostics.BeforeViewComponent.EventName,
new new BeforeViewComponent(
{ context.ViewContext.ActionDescriptor,
actionDescriptor = context.ViewContext.ActionDescriptor, context,
viewComponentContext = context, viewComponent
viewComponent = viewComponent ));
});
} }
} }
@ -53,17 +53,16 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
private static void AfterViewComponentImpl(DiagnosticListener diagnosticListener, ViewComponentContext context, IViewComponentResult result, object viewComponent) private static void AfterViewComponentImpl(DiagnosticListener diagnosticListener, ViewComponentContext context, IViewComponentResult result, object viewComponent)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterViewComponent")) if (diagnosticListener.IsEnabled(Diagnostics.AfterViewComponent.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterViewComponent", Diagnostics.AfterViewComponent.EventName,
new new AfterViewComponent(
{ context.ViewContext.ActionDescriptor,
actionDescriptor = context.ViewContext.ActionDescriptor, context,
viewComponentContext = context, result,
viewComponentResult = result, viewComponent
viewComponent = viewComponent ));
});
} }
} }
@ -81,16 +80,15 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
private static void ViewComponentBeforeViewExecuteImpl(DiagnosticListener diagnosticListener, ViewComponentContext context, IView view) private static void ViewComponentBeforeViewExecuteImpl(DiagnosticListener diagnosticListener, ViewComponentContext context, IView view)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.ViewComponentBeforeViewExecute")) if (diagnosticListener.IsEnabled(Diagnostics.ViewComponentBeforeViewExecute.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.ViewComponentBeforeViewExecute", Diagnostics.ViewComponentBeforeViewExecute.EventName,
new new ViewComponentBeforeViewExecute(
{ context.ViewContext.ActionDescriptor,
actionDescriptor = context.ViewContext.ActionDescriptor, context,
viewComponentContext = context, view
view = view ));
});
} }
} }
@ -108,16 +106,15 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
private static void ViewComponentAfterViewExecuteImpl(DiagnosticListener diagnosticListener, ViewComponentContext context, IView view) private static void ViewComponentAfterViewExecuteImpl(DiagnosticListener diagnosticListener, ViewComponentContext context, IView view)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.ViewComponentAfterViewExecute")) if (diagnosticListener.IsEnabled(Diagnostics.ViewComponentAfterViewExecute.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.ViewComponentAfterViewExecute", Diagnostics.ViewComponentAfterViewExecute.EventName,
new new ViewComponentAfterViewExecute(
{ context.ViewContext.ActionDescriptor,
actionDescriptor = context.ViewContext.ActionDescriptor, context,
viewComponentContext = context, view
view = view ));
});
} }
} }
@ -135,11 +132,11 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
private static void BeforeViewImpl(DiagnosticListener diagnosticListener, IView view, ViewContext viewContext) private static void BeforeViewImpl(DiagnosticListener diagnosticListener, IView view, ViewContext viewContext)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeView")) if (diagnosticListener.IsEnabled(Diagnostics.BeforeView.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.BeforeView", Diagnostics.BeforeView.EventName,
new { view = view, viewContext = viewContext, }); new BeforeView(view, viewContext));
} }
} }
@ -157,11 +154,11 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
private static void AfterViewImpl(DiagnosticListener diagnosticListener, IView view, ViewContext viewContext) private static void AfterViewImpl(DiagnosticListener diagnosticListener, IView view, ViewContext viewContext)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterView")) if (diagnosticListener.IsEnabled(Diagnostics.AfterView.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.AfterView", Diagnostics.AfterView.EventName,
new { view = view, viewContext = viewContext, }); new AfterView(view, viewContext));
} }
} }
@ -169,7 +166,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
this DiagnosticListener diagnosticListener, this DiagnosticListener diagnosticListener,
ActionContext actionContext, ActionContext actionContext,
bool isMainPage, bool isMainPage,
PartialViewResult viewResult, ActionResult viewResult,
string viewName, string viewName,
IView view) IView view)
{ {
@ -180,20 +177,19 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
} }
} }
private static void ViewFoundImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, bool isMainPage, PartialViewResult viewResult, string viewName, IView view) private static void ViewFoundImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, bool isMainPage, ActionResult viewResult, string viewName, IView view)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.ViewFound")) if (diagnosticListener.IsEnabled(Diagnostics.ViewFound.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.ViewFound", Diagnostics.ViewFound.EventName,
new new ViewFound(
{ actionContext,
actionContext = actionContext, isMainPage,
isMainPage = isMainPage, viewResult,
result = viewResult, viewName,
viewName = viewName, view
view = view, ));
});
} }
} }
@ -201,7 +197,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
this DiagnosticListener diagnosticListener, this DiagnosticListener diagnosticListener,
ActionContext actionContext, ActionContext actionContext,
bool isMainPage, bool isMainPage,
PartialViewResult viewResult, ActionResult viewResult,
string viewName, string viewName,
IEnumerable<string> searchedLocations) IEnumerable<string> searchedLocations)
{ {
@ -212,20 +208,19 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
} }
} }
private static void ViewNotFoundImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, bool isMainPage, PartialViewResult viewResult, string viewName, IEnumerable<string> searchedLocations) private static void ViewNotFoundImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, bool isMainPage, ActionResult viewResult, string viewName, IEnumerable<string> searchedLocations)
{ {
if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.ViewNotFound")) if (diagnosticListener.IsEnabled(Diagnostics.ViewNotFound.EventName))
{ {
diagnosticListener.Write( diagnosticListener.Write(
"Microsoft.AspNetCore.Mvc.ViewNotFound", Diagnostics.ViewNotFound.EventName,
new new ViewNotFound(
{ actionContext,
actionContext = actionContext, isMainPage,
isMainPage = isMainPage, viewResult,
result = viewResult, viewName,
viewName = viewName, searchedLocations
searchedLocations = searchedLocations, ));
});
} }
} }
} }

View File

@ -108,7 +108,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
if (result.Success) if (result.Success)
{ {
DiagnosticSource.ViewFound( DiagnosticListener.ViewFound(
actionContext, actionContext,
isMainPage: false, isMainPage: false,
viewResult: viewResult, viewResult: viewResult,
@ -119,7 +119,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
} }
else else
{ {
DiagnosticSource.ViewNotFound( DiagnosticListener.ViewNotFound(
actionContext, actionContext,
isMainPage: false, isMainPage: false,
viewResult: viewResult, viewResult: viewResult,

View File

@ -32,7 +32,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
/// <param name="writerFactory">The <see cref="IHttpResponseStreamWriterFactory"/>.</param> /// <param name="writerFactory">The <see cref="IHttpResponseStreamWriterFactory"/>.</param>
/// <param name="viewEngine">The <see cref="ICompositeViewEngine"/>.</param> /// <param name="viewEngine">The <see cref="ICompositeViewEngine"/>.</param>
/// <param name="tempDataFactory">The <see cref="ITempDataDictionaryFactory"/>.</param> /// <param name="tempDataFactory">The <see cref="ITempDataDictionaryFactory"/>.</param>
/// <param name="diagnosticListener">The <see cref="DiagnosticSource"/>.</param> /// <param name="diagnosticListener">The <see cref="DiagnosticListener"/>.</param>
/// <param name="modelMetadataProvider">The <see cref="IModelMetadataProvider" />.</param> /// <param name="modelMetadataProvider">The <see cref="IModelMetadataProvider" />.</param>
public ViewExecutor( public ViewExecutor(
IOptions<MvcViewOptions> viewOptions, IOptions<MvcViewOptions> viewOptions,
@ -91,13 +91,13 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
WriterFactory = writerFactory; WriterFactory = writerFactory;
ViewEngine = viewEngine; ViewEngine = viewEngine;
DiagnosticSource = diagnosticListener; DiagnosticListener = diagnosticListener;
} }
/// <summary> /// <summary>
/// Gets the <see cref="DiagnosticSource"/>. /// Gets the <see cref="DiagnosticListener"/>.
/// </summary> /// </summary>
protected DiagnosticListener DiagnosticSource { get; } protected DiagnosticListener DiagnosticListener { get; }
/// <summary> /// <summary>
/// Gets the <see cref="ITempDataDictionaryFactory"/>. /// Gets the <see cref="ITempDataDictionaryFactory"/>.
@ -242,11 +242,11 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
{ {
viewContext.Writer = writer; viewContext.Writer = writer;
DiagnosticSource.BeforeView(view, viewContext); DiagnosticListener.BeforeView(view, viewContext);
await view.RenderAsync(viewContext); await view.RenderAsync(viewContext);
DiagnosticSource.AfterView(view, viewContext); DiagnosticListener.AfterView(view, viewContext);
} }
finally finally
{ {

View File

@ -107,7 +107,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
} }
} }
if (DiagnosticSource.IsEnabled()) if (DiagnosticListener.IsEnabled())
{ {
OutputDiagnostics(actionContext, viewResult, viewName, stopwatch, result); OutputDiagnostics(actionContext, viewResult, viewName, stopwatch, result);
} }
@ -128,35 +128,21 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
{ {
if (result.Success) if (result.Success)
{ {
if (DiagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.ViewFound")) DiagnosticListener.ViewFound(
{ actionContext,
DiagnosticSource.Write( isMainPage: true,
"Microsoft.AspNetCore.Mvc.ViewFound", viewResult,
new viewName,
{ view: result.View);
actionContext,
isMainPage = true,
result = viewResult,
viewName,
view = result.View,
});
}
} }
else else
{ {
if (DiagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.ViewNotFound")) DiagnosticListener.ViewNotFound(
{ actionContext,
DiagnosticSource.Write( isMainPage: true,
"Microsoft.AspNetCore.Mvc.ViewNotFound", viewResult,
new viewName,
{ searchedLocations: result.SearchedLocations);
actionContext,
isMainPage = true,
result = viewResult,
viewName,
searchedLocations = result.SearchedLocations
});
}
} }
} }

View File

@ -264,7 +264,7 @@ namespace Microsoft.AspNetCore.Mvc
} }
[Fact] [Fact]
public async Task ExecuteResultAsync_ExecutesViewComponent_AndWritesDiagnosticSource() public async Task ExecuteResultAsync_ExecutesViewComponent_AndWritesDiagnosticListener()
{ {
// Arrange // Arrange
var methodInfo = typeof(TextViewComponent).GetMethod(nameof(TextViewComponent.Invoke)); var methodInfo = typeof(TextViewComponent).GetMethod(nameof(TextViewComponent.Invoke));

View File

@ -102,7 +102,7 @@ namespace Microsoft.AspNetCore.Mvc
} }
[Fact] [Fact]
public void Execute_ResolvesView_AndWritesDiagnosticSource() public void Execute_ResolvesView_AndWritesDiagnosticListener()
{ {
// Arrange // Arrange
var view = new Mock<IView>(MockBehavior.Strict); var view = new Mock<IView>(MockBehavior.Strict);