diff --git a/src/Hosting/Hosting/test/HostingApplicationTests.cs b/src/Hosting/Hosting/test/HostingApplicationTests.cs index fd8680100de8..64d832eb0c5a 100644 --- a/src/Hosting/Hosting/test/HostingApplicationTests.cs +++ b/src/Hosting/Hosting/test/HostingApplicationTests.cs @@ -88,13 +88,13 @@ public void CreateContextWithEnabledLoggerAndRequestIdCreatesActivityAndSetsActi public void ActivityStopDoesNotFireIfNoListenerAttachedForStart() { // Arrange - var diagnosticSource = new DiagnosticListener("DummySource"); + var diagnosticListener = new DiagnosticListener("DummySource"); 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 stopFired = false; - diagnosticSource.Subscribe(new CallbackDiagnosticListener(pair => + diagnosticListener.Subscribe(new CallbackDiagnosticListener(pair => { // This should not fire if (pair.Key == "Microsoft.AspNetCore.Hosting.HttpRequestIn.Start") @@ -128,14 +128,14 @@ public void ActivityStopDoesNotFireIfNoListenerAttachedForStart() [Fact] public void ActivityIsNotCreatedWhenIsEnabledForActivityIsFalse() { - var diagnosticSource = new DiagnosticListener("DummySource"); - var hostingApplication = CreateApplication(out var features, diagnosticSource: diagnosticSource); + var diagnosticListener = new DiagnosticListener("DummySource"); + var hostingApplication = CreateApplication(out var features, diagnosticListener: diagnosticListener); bool eventsFired = false; bool isEnabledActivityFired = false; bool isEnabledStartFired = false; - diagnosticSource.Subscribe(new CallbackDiagnosticListener(pair => + diagnosticListener.Subscribe(new CallbackDiagnosticListener(pair => { eventsFired |= pair.Key.StartsWith("Microsoft.AspNetCore.Hosting.HttpRequestIn"); }), (s, o, arg3) => @@ -162,14 +162,14 @@ public void ActivityIsNotCreatedWhenIsEnabledForActivityIsFalse() [Fact] public void ActivityIsCreatedButNotLoggedWhenIsEnabledForActivityStartIsFalse() { - var diagnosticSource = new DiagnosticListener("DummySource"); - var hostingApplication = CreateApplication(out var features, diagnosticSource: diagnosticSource); + var diagnosticListener = new DiagnosticListener("DummySource"); + var hostingApplication = CreateApplication(out var features, diagnosticListener: diagnosticListener); bool eventsFired = false; bool isEnabledStartFired = false; bool isEnabledActivityFired = false; - diagnosticSource.Subscribe(new CallbackDiagnosticListener(pair => + diagnosticListener.Subscribe(new CallbackDiagnosticListener(pair => { eventsFired |= pair.Key.StartsWith("Microsoft.AspNetCore.Hosting.HttpRequestIn"); }), (s, o, arg3) => @@ -199,12 +199,12 @@ public void ActivityIsCreatedButNotLoggedWhenIsEnabledForActivityStartIsFalse() [Fact] public void ActivityIsCreatedAndLogged() { - var diagnosticSource = new DiagnosticListener("DummySource"); - var hostingApplication = CreateApplication(out var features, diagnosticSource: diagnosticSource); + var diagnosticListener = new DiagnosticListener("DummySource"); + var hostingApplication = CreateApplication(out var features, diagnosticListener: diagnosticListener); bool startCalled = false; - diagnosticSource.Subscribe(new CallbackDiagnosticListener(pair => + diagnosticListener.Subscribe(new CallbackDiagnosticListener(pair => { if (pair.Key == "Microsoft.AspNetCore.Hosting.HttpRequestIn.Start") { @@ -224,11 +224,11 @@ public void ActivityIsCreatedAndLogged() [Fact] public void ActivityIsStoppedDuringStopCall() { - var diagnosticSource = new DiagnosticListener("DummySource"); - var hostingApplication = CreateApplication(out var features, diagnosticSource: diagnosticSource); + var diagnosticListener = new DiagnosticListener("DummySource"); + var hostingApplication = CreateApplication(out var features, diagnosticListener: diagnosticListener); bool endCalled = false; - diagnosticSource.Subscribe(new CallbackDiagnosticListener(pair => + diagnosticListener.Subscribe(new CallbackDiagnosticListener(pair => { if (pair.Key == "Microsoft.AspNetCore.Hosting.HttpRequestIn.Stop") { @@ -249,11 +249,11 @@ public void ActivityIsStoppedDuringStopCall() [Fact] public void ActivityIsStoppedDuringUnhandledExceptionCall() { - var diagnosticSource = new DiagnosticListener("DummySource"); - var hostingApplication = CreateApplication(out var features, diagnosticSource: diagnosticSource); + var diagnosticListener = new DiagnosticListener("DummySource"); + var hostingApplication = CreateApplication(out var features, diagnosticListener: diagnosticListener); bool endCalled = false; - diagnosticSource.Subscribe(new CallbackDiagnosticListener(pair => + diagnosticListener.Subscribe(new CallbackDiagnosticListener(pair => { if (pair.Key == "Microsoft.AspNetCore.Hosting.HttpRequestIn.Stop") { @@ -273,11 +273,11 @@ public void ActivityIsStoppedDuringUnhandledExceptionCall() [Fact] public void ActivityIsAvailableDuringUnhandledExceptionCall() { - var diagnosticSource = new DiagnosticListener("DummySource"); - var hostingApplication = CreateApplication(out var features, diagnosticSource: diagnosticSource); + var diagnosticListener = new DiagnosticListener("DummySource"); + var hostingApplication = CreateApplication(out var features, diagnosticListener: diagnosticListener); bool endCalled = false; - diagnosticSource.Subscribe(new CallbackDiagnosticListener(pair => + diagnosticListener.Subscribe(new CallbackDiagnosticListener(pair => { if (pair.Key == "Microsoft.AspNetCore.Hosting.UnhandledException") { @@ -295,10 +295,10 @@ public void ActivityIsAvailableDuringUnhandledExceptionCall() [Fact] public void ActivityIsAvailibleDuringRequest() { - var diagnosticSource = new DiagnosticListener("DummySource"); - var hostingApplication = CreateApplication(out var features, diagnosticSource: diagnosticSource); + var diagnosticListener = new DiagnosticListener("DummySource"); + var hostingApplication = CreateApplication(out var features, diagnosticListener: diagnosticListener); - diagnosticSource.Subscribe(new CallbackDiagnosticListener(pair => { }), + diagnosticListener.Subscribe(new CallbackDiagnosticListener(pair => { }), s => { if (s.StartsWith("Microsoft.AspNetCore.Hosting.HttpRequestIn")) @@ -317,10 +317,10 @@ public void ActivityIsAvailibleDuringRequest() [Fact] public void ActivityParentIdAndBaggeReadFromHeaders() { - var diagnosticSource = new DiagnosticListener("DummySource"); - var hostingApplication = CreateApplication(out var features, diagnosticSource: diagnosticSource); + var diagnosticListener = new DiagnosticListener("DummySource"); + var hostingApplication = CreateApplication(out var features, diagnosticListener: diagnosticListener); - diagnosticSource.Subscribe(new CallbackDiagnosticListener(pair => { }), + diagnosticListener.Subscribe(new CallbackDiagnosticListener(pair => { }), s => { if (s.StartsWith("Microsoft.AspNetCore.Hosting.HttpRequestIn")) @@ -349,10 +349,10 @@ public void ActivityParentIdAndBaggeReadFromHeaders() [Fact] public void ActivityTraceParentAndTraceStateFromHeaders() { - var diagnosticSource = new DiagnosticListener("DummySource"); - var hostingApplication = CreateApplication(out var features, diagnosticSource: diagnosticSource); + var diagnosticListener = new DiagnosticListener("DummySource"); + var hostingApplication = CreateApplication(out var features, diagnosticListener: diagnosticListener); - diagnosticSource.Subscribe(new CallbackDiagnosticListener(pair => { }), + diagnosticListener.Subscribe(new CallbackDiagnosticListener(pair => { }), s => { if (s.StartsWith("Microsoft.AspNetCore.Hosting.HttpRequestIn")) @@ -385,11 +385,11 @@ public void ActivityTraceParentAndTraceStateFromHeaders() [Fact] public void ActivityOnExportHookIsCalled() { - var diagnosticSource = new DiagnosticListener("DummySource"); - var hostingApplication = CreateApplication(out var features, diagnosticSource: diagnosticSource); + var diagnosticListener = new DiagnosticListener("DummySource"); + var hostingApplication = CreateApplication(out var features, diagnosticListener: diagnosticListener); bool onActivityImportCalled = false; - diagnosticSource.Subscribe( + diagnosticListener.Subscribe( observer: new CallbackDiagnosticListener(pair => { }), isEnabled: (s, o, _) => true, onActivityImport: (activity, context) => @@ -422,7 +422,7 @@ private static void AssertProperty(object o, string name) } private static HostingApplication CreateApplication(out FeatureCollection features, - DiagnosticListener diagnosticSource = null, ILogger logger = null, Action configure = null) + DiagnosticListener diagnosticListener = null, ILogger logger = null, Action configure = null) { var httpContextFactory = new Mock(); @@ -436,7 +436,7 @@ private static HostingApplication CreateApplication(out FeatureCollection featur var hostingApplication = new HostingApplication( ctx => Task.CompletedTask, logger ?? new NullScopeLogger(), - diagnosticSource ?? new NoopDiagnosticSource(), + diagnosticListener ?? new NoopDiagnosticListener(), httpContextFactory.Object); return hostingApplication; @@ -490,11 +490,11 @@ public void Dispose() } } - private class NoopDiagnosticSource : DiagnosticListener + private class NoopDiagnosticListener : DiagnosticListener { private readonly bool _isEnabled; - public NoopDiagnosticSource(bool isEnabled = false) : base("DummyListener") + public NoopDiagnosticListener(bool isEnabled = false) : base("DummyListener") { _isEnabled = isEnabled; } diff --git a/src/Http/Http/src/DefaultHttpContext.cs b/src/Http/Http/src/DefaultHttpContext.cs index cbc24490585f..60e0a185a601 100644 --- a/src/Http/Http/src/DefaultHttpContext.cs +++ b/src/Http/Http/src/DefaultHttpContext.cs @@ -159,7 +159,7 @@ public override ISession Session // This property exists because of backwards compatibility. // 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 [EditorBrowsable(EditorBrowsableState.Never)] public HttpContext HttpContext => this; diff --git a/src/Mvc/Mvc.Core/ref/Microsoft.AspNetCore.Mvc.Core.netcoreapp3.0.cs b/src/Mvc/Mvc.Core/ref/Microsoft.AspNetCore.Mvc.Core.netcoreapp3.0.cs index a895709b2478..125028635853 100644 --- a/src/Mvc/Mvc.Core/ref/Microsoft.AspNetCore.Mvc.Core.netcoreapp3.0.cs +++ b/src/Mvc/Mvc.Core/ref/Microsoft.AspNetCore.Mvc.Core.netcoreapp3.0.cs @@ -1718,6 +1718,310 @@ public partial interface IAntiforgeryValidationFailedResult : Microsoft.AspNetCo { } } +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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 arguments, object controller) { } + public Microsoft.AspNetCore.Mvc.ActionContext ActionContext { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } } + public System.Collections.Generic.IReadOnlyDictionary 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 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 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 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 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 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 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 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 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 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 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 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 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 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.IReadOnlyCollection>, System.Collections.Generic.IReadOnlyList>, System.Collections.IEnumerable + { + protected const string EventNamespace = "Microsoft.AspNetCore.Mvc."; + protected EventData() { } + protected abstract int Count { get; } + protected abstract System.Collections.Generic.KeyValuePair this[int index] { get; } + int System.Collections.Generic.IReadOnlyCollection>.Count { get { throw null; } } + System.Collections.Generic.KeyValuePair System.Collections.Generic.IReadOnlyList>.this[int index] { get { throw null; } } + System.Collections.Generic.IEnumerator> System.Collections.Generic.IEnumerable>.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.IEnumerator, System.IDisposable + { + private object _dummy; + private int _dummyPrimitive; + public System.Collections.Generic.KeyValuePair 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 { [System.AttributeUsageAttribute(System.AttributeTargets.Class | System.AttributeTargets.Method, AllowMultiple=true, Inherited=true)] diff --git a/src/Mvc/Mvc.Core/src/Diagnostics/EventData.cs b/src/Mvc/Mvc.Core/src/Diagnostics/EventData.cs new file mode 100644 index 000000000000..b9d064c31410 --- /dev/null +++ b/src/Mvc/Mvc.Core/src/Diagnostics/EventData.cs @@ -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> + { + protected const string EventNamespace = "Microsoft.AspNetCore.Mvc."; + + protected abstract int Count { get; } + protected abstract KeyValuePair this[int index] { get; } + + int IReadOnlyCollection>.Count => Count; + KeyValuePair IReadOnlyList>.this[int index] => this[index]; + + Enumerator GetEnumerator() => new Enumerator(this); + + IEnumerator> IEnumerable>.GetEnumerator() + => GetEnumerator(); + + IEnumerator IEnumerable.GetEnumerator() + => GetEnumerator(); + + public struct Enumerator : IEnumerator> + { + private readonly EventData _eventData; + private readonly int _count; + + private int _index; + + public KeyValuePair 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(); + } + } +} diff --git a/src/Mvc/Mvc.Core/src/Diagnostics/MvcDiagnostics.cs b/src/Mvc/Mvc.Core/src/Diagnostics/MvcDiagnostics.cs new file mode 100644 index 000000000000..8c98d8f30278 --- /dev/null +++ b/src/Mvc/Mvc.Core/src/Diagnostics/MvcDiagnostics.cs @@ -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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(HttpContext), HttpContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(HttpContext), HttpContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(AuthorizationContext), AuthorizationContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(AuthorizationContext), AuthorizationContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(ResourceExecutingContext), ResourceExecutingContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(ResourceExecutedContext), ResourceExecutedContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(ResourceExecutingContext), ResourceExecutingContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(ResourceExecutingContext), ResourceExecutingContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(ResourceExecutedContext), ResourceExecutedContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(ResourceExecutedContext), ResourceExecutedContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(ExceptionContext), ExceptionContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(ExceptionContext), ExceptionContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(ActionExecutingContext), ActionExecutingContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(ActionExecutedContext), ActionExecutedContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(ActionExecutingContext), ActionExecutingContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(ActionExecutingContext), ActionExecutingContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(ActionExecutedContext), ActionExecutedContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(ActionExecutedContext), ActionExecutedContext), + 2 => new KeyValuePair(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 arguments, object controller) + { + ActionContext = actionContext; + Arguments = arguments; + Controller = controller; + } + + public ActionContext ActionContext { get; } + public IReadOnlyDictionary Arguments { get; } + public object Controller { get; } + + protected override int Count => 3; + + protected override KeyValuePair this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionContext), ActionContext), + 1 => new KeyValuePair(nameof(Arguments), Arguments), + 2 => new KeyValuePair(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 arguments, object controller, IActionResult result) + { + ActionContext = actionContext; + Arguments = arguments; + Controller = controller; + Result = result; + } + + public ActionContext ActionContext { get; } + public IReadOnlyDictionary Arguments { get; } + public object Controller { get; } + public IActionResult Result { get; } + + protected override int Count => 4; + + protected override KeyValuePair this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionContext), ActionContext), + 1 => new KeyValuePair(nameof(Controller), Controller), + 2 => new KeyValuePair(nameof(Controller), Controller), + 3 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(ResultExecutingContext), ResultExecutingContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(ResultExecutedContext), ResultExecutedContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(ResultExecutingContext), ResultExecutingContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(ResultExecutingContext), ResultExecutingContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(ResultExecutedContext), ResultExecutedContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(ResultExecutedContext), ResultExecutedContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionContext), ActionContext), + 1 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionContext), ActionContext), + 1 => new KeyValuePair(nameof(Result), Result), + _ => throw new IndexOutOfRangeException(nameof(index)) + }; + } +} \ No newline at end of file diff --git a/src/Mvc/Mvc.Core/src/MvcCoreDiagnosticSourceExtensions.cs b/src/Mvc/Mvc.Core/src/MvcCoreDiagnosticListenerExtensions.cs similarity index 68% rename from src/Mvc/Mvc.Core/src/MvcCoreDiagnosticSourceExtensions.cs rename to src/Mvc/Mvc.Core/src/MvcCoreDiagnosticListenerExtensions.cs index 32085e7da866..89ff1bc905a0 100644 --- a/src/Mvc/Mvc.Core/src/MvcCoreDiagnosticSourceExtensions.cs +++ b/src/Mvc/Mvc.Core/src/MvcCoreDiagnosticListenerExtensions.cs @@ -5,6 +5,7 @@ using System.Diagnostics; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc.Abstractions; +using Microsoft.AspNetCore.Mvc.Diagnostics; using Microsoft.AspNetCore.Mvc.Filters; 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 // 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. - internal static class MvcCoreDiagnosticSourceExtensions + internal static class MvcCoreDiagnosticListenerExtensions { public static void BeforeAction( this DiagnosticListener diagnosticListener, @@ -35,11 +36,11 @@ public static void BeforeAction( 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( - "Microsoft.AspNetCore.Mvc.BeforeAction", - new { actionDescriptor, httpContext = httpContext, routeData = routeData }); + Diagnostics.BeforeAction.EventName, + new BeforeAction(actionDescriptor, httpContext, routeData)); } } @@ -63,11 +64,11 @@ public static void AfterAction( 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( - "Microsoft.AspNetCore.Mvc.AfterAction", - new { actionDescriptor, httpContext = httpContext, routeData = routeData }); + Diagnostics.AfterAction.EventName, + new AfterAction(actionDescriptor, httpContext, routeData)); } } @@ -89,16 +90,15 @@ public static void BeforeOnAuthorizationAsync( 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( - "Microsoft.AspNetCore.Mvc.BeforeOnAuthorization", - new - { - actionDescriptor = authorizationContext.ActionDescriptor, - authorizationContext = authorizationContext, - filter = filter - }); + Diagnostics.BeforeOnAuthorization.EventName, + new BeforeOnAuthorization( + authorizationContext.ActionDescriptor, + authorizationContext, + filter + )); } } @@ -120,16 +120,15 @@ public static void AfterOnAuthorizationAsync( 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( - "Microsoft.AspNetCore.Mvc.AfterOnAuthorization", - new - { - actionDescriptor = authorizationContext.ActionDescriptor, - authorizationContext = authorizationContext, - filter = filter - }); + Diagnostics.AfterOnAuthorization.EventName, + new AfterOnAuthorization( + authorizationContext.ActionDescriptor, + authorizationContext, + filter + )); } } @@ -151,16 +150,15 @@ public static void BeforeOnAuthorization( 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( - "Microsoft.AspNetCore.Mvc.BeforeOnAuthorization", - new - { - actionDescriptor = authorizationContext.ActionDescriptor, - authorizationContext = authorizationContext, - filter = filter - }); + Diagnostics.BeforeOnAuthorization.EventName, + new BeforeOnAuthorization( + authorizationContext.ActionDescriptor, + authorizationContext, + filter + )); } } @@ -182,16 +180,15 @@ public static void AfterOnAuthorization( 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( - "Microsoft.AspNetCore.Mvc.AfterOnAuthorization", - new - { - actionDescriptor = authorizationContext.ActionDescriptor, - authorizationContext = authorizationContext, - filter = filter - }); + Diagnostics.AfterOnAuthorization.EventName, + new AfterOnAuthorization( + authorizationContext.ActionDescriptor, + authorizationContext, + filter + )); } } @@ -213,16 +210,15 @@ public static void BeforeOnResourceExecution( 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( - "Microsoft.AspNetCore.Mvc.BeforeOnResourceExecution", - new - { - actionDescriptor = resourceExecutingContext.ActionDescriptor, - resourceExecutingContext = resourceExecutingContext, - filter = filter - }); + Diagnostics.BeforeOnResourceExecution.EventName, + new BeforeOnResourceExecution( + resourceExecutingContext.ActionDescriptor, + resourceExecutingContext, + filter + )); } } @@ -244,16 +240,15 @@ public static void AfterOnResourceExecution( 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( - "Microsoft.AspNetCore.Mvc.AfterOnResourceExecution", - new - { - actionDescriptor = resourceExecutedContext.ActionDescriptor, - resourceExecutedContext = resourceExecutedContext, - filter = filter - }); + Diagnostics.AfterOnResourceExecution.EventName, + new AfterOnResourceExecution( + resourceExecutedContext.ActionDescriptor, + resourceExecutedContext, + filter + )); } } @@ -275,16 +270,15 @@ public static void BeforeOnResourceExecuting( 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( - "Microsoft.AspNetCore.Mvc.BeforeOnResourceExecuting", - new - { - actionDescriptor = resourceExecutingContext.ActionDescriptor, - resourceExecutingContext = resourceExecutingContext, - filter = filter - }); + Diagnostics.BeforeOnResourceExecuting.EventName, + new BeforeOnResourceExecuting( + resourceExecutingContext.ActionDescriptor, + resourceExecutingContext, + filter + )); } } @@ -306,16 +300,15 @@ public static void AfterOnResourceExecuting( 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( - "Microsoft.AspNetCore.Mvc.AfterOnResourceExecuting", - new - { - actionDescriptor = resourceExecutingContext.ActionDescriptor, - resourceExecutingContext = resourceExecutingContext, - filter = filter - }); + Diagnostics.AfterOnResourceExecuting.EventName, + new AfterOnResourceExecuting( + resourceExecutingContext.ActionDescriptor, + resourceExecutingContext, + filter + )); } } @@ -337,16 +330,15 @@ public static void BeforeOnResourceExecuted( 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( - "Microsoft.AspNetCore.Mvc.BeforeOnResourceExecuted", - new - { - actionDescriptor = resourceExecutedContext.ActionDescriptor, - resourceExecutedContext = resourceExecutedContext, - filter = filter - }); + Diagnostics.BeforeOnResourceExecuted.EventName, + new BeforeOnResourceExecuted( + resourceExecutedContext.ActionDescriptor, + resourceExecutedContext, + filter + )); } } @@ -368,16 +360,15 @@ public static void AfterOnResourceExecuted( 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( - "Microsoft.AspNetCore.Mvc.AfterOnResourceExecuted", - new - { - actionDescriptor = resourceExecutedContext.ActionDescriptor, - resourceExecutedContext = resourceExecutedContext, - filter = filter - }); + Diagnostics.AfterOnResourceExecuted.EventName, + new AfterOnResourceExecuted( + resourceExecutedContext.ActionDescriptor, + resourceExecutedContext, + filter + )); } } @@ -399,16 +390,15 @@ public static void BeforeOnExceptionAsync( 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( - "Microsoft.AspNetCore.Mvc.BeforeOnException", - new - { - actionDescriptor = exceptionContext.ActionDescriptor, - exceptionContext = exceptionContext, - filter = filter - }); + Diagnostics.BeforeOnException.EventName, + new BeforeOnException( + exceptionContext.ActionDescriptor, + exceptionContext, + filter + )); } } @@ -430,16 +420,15 @@ public static void AfterOnExceptionAsync( 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( - "Microsoft.AspNetCore.Mvc.AfterOnException", - new - { - actionDescriptor = exceptionContext.ActionDescriptor, - exceptionContext = exceptionContext, - filter = filter - }); + Diagnostics.AfterOnException.EventName, + new AfterOnException( + exceptionContext.ActionDescriptor, + exceptionContext, + filter + )); } } @@ -461,16 +450,15 @@ public static void BeforeOnException( 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( - "Microsoft.AspNetCore.Mvc.BeforeOnException", - new - { - actionDescriptor = exceptionContext.ActionDescriptor, - exceptionContext = exceptionContext, - filter = filter - }); + Diagnostics.BeforeOnException.EventName, + new BeforeOnException( + exceptionContext.ActionDescriptor, + exceptionContext, + filter + )); } } @@ -492,16 +480,15 @@ public static void AfterOnException( 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( - "Microsoft.AspNetCore.Mvc.AfterOnException", - new - { - actionDescriptor = exceptionContext.ActionDescriptor, - exceptionContext = exceptionContext, - filter = filter - }); + Diagnostics.AfterOnException.EventName, + new AfterOnException( + exceptionContext.ActionDescriptor, + exceptionContext, + filter + )); } } @@ -523,16 +510,15 @@ public static void BeforeOnActionExecution( 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( - "Microsoft.AspNetCore.Mvc.BeforeOnActionExecution", - new - { - actionDescriptor = actionExecutingContext.ActionDescriptor, - actionExecutingContext = actionExecutingContext, - filter = filter - }); + Diagnostics.BeforeOnActionExecution.EventName, + new BeforeOnActionExecution( + actionExecutingContext.ActionDescriptor, + actionExecutingContext, + filter + )); } } @@ -554,16 +540,15 @@ public static void AfterOnActionExecution( 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( - "Microsoft.AspNetCore.Mvc.AfterOnActionExecution", - new - { - actionDescriptor = actionExecutedContext.ActionDescriptor, - actionExecutedContext = actionExecutedContext, - filter = filter - }); + Diagnostics.AfterOnActionExecution.EventName, + new AfterOnActionExecution( + actionExecutedContext.ActionDescriptor, + actionExecutedContext, + filter + )); } } @@ -585,16 +570,15 @@ public static void BeforeOnActionExecuting( 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( - "Microsoft.AspNetCore.Mvc.BeforeOnActionExecuting", - new - { - actionDescriptor = actionExecutingContext.ActionDescriptor, - actionExecutingContext = actionExecutingContext, - filter = filter - }); + Diagnostics.BeforeOnActionExecuting.EventName, + new BeforeOnActionExecuting( + actionExecutingContext.ActionDescriptor, + actionExecutingContext, + filter + )); } } @@ -616,16 +600,15 @@ public static void AfterOnActionExecuting( 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( - "Microsoft.AspNetCore.Mvc.AfterOnActionExecuting", - new - { - actionDescriptor = actionExecutingContext.ActionDescriptor, - actionExecutingContext = actionExecutingContext, - filter = filter - }); + Diagnostics.AfterOnActionExecuting.EventName, + new AfterOnActionExecuting( + actionExecutingContext.ActionDescriptor, + actionExecutingContext, + filter + )); } } @@ -647,16 +630,15 @@ public static void BeforeOnActionExecuted( 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( - "Microsoft.AspNetCore.Mvc.BeforeOnActionExecuted", - new - { - actionDescriptor = actionExecutedContext.ActionDescriptor, - actionExecutedContext = actionExecutedContext, - filter = filter - }); + Diagnostics.BeforeOnActionExecuted.EventName, + new BeforeOnActionExecuted( + actionExecutedContext.ActionDescriptor, + actionExecutedContext, + filter + )); } } @@ -678,23 +660,22 @@ public static void AfterOnActionExecuted( 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( - "Microsoft.AspNetCore.Mvc.AfterOnActionExecuted", - new - { - actionDescriptor = actionExecutedContext.ActionDescriptor, - actionExecutedContext = actionExecutedContext, - filter = filter - }); + Diagnostics.AfterOnActionExecuted.EventName, + new AfterOnActionExecuted( + actionExecutedContext.ActionDescriptor, + actionExecutedContext, + filter + )); } } public static void BeforeActionMethod( this DiagnosticListener diagnosticListener, ActionContext actionContext, - IDictionary actionArguments, + IReadOnlyDictionary actionArguments, object controller) { Debug.Assert(diagnosticListener != null); @@ -709,25 +690,24 @@ public static void BeforeActionMethod( } } - private static void BeforeActionMethodImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, IDictionary actionArguments, object controller) + private static void BeforeActionMethodImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, IReadOnlyDictionary actionArguments, object controller) { - if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeActionMethod")) + if (diagnosticListener.IsEnabled(Diagnostics.BeforeActionMethod.EventName)) { diagnosticListener.Write( - "Microsoft.AspNetCore.Mvc.BeforeActionMethod", - new - { - actionContext = actionContext, - arguments = actionArguments, - controller = controller - }); + Diagnostics.BeforeActionMethod.EventName, + new BeforeActionMethod( + actionContext, + actionArguments, + controller + )); } } public static void AfterActionMethod( this DiagnosticListener diagnosticListener, ActionContext actionContext, - IDictionary actionArguments, + IReadOnlyDictionary actionArguments, object controller, IActionResult result) { @@ -743,19 +723,18 @@ public static void AfterActionMethod( } } - private static void AfterActionMethodImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, IDictionary actionArguments, object controller, IActionResult result) + private static void AfterActionMethodImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, IReadOnlyDictionary actionArguments, object controller, IActionResult result) { - if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterActionMethod")) + if (diagnosticListener.IsEnabled(Diagnostics.AfterActionMethod.EventName)) { diagnosticListener.Write( - "Microsoft.AspNetCore.Mvc.AfterActionMethod", - new - { - actionContext = actionContext, - arguments = actionArguments, - controller = controller, - result = result - }); + Diagnostics.AfterActionMethod.EventName, + new AfterActionMethod( + actionContext, + actionArguments, + controller, + result + )); } } @@ -777,16 +756,15 @@ public static void BeforeOnResultExecution( 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( - "Microsoft.AspNetCore.Mvc.BeforeOnResultExecution", - new - { - actionDescriptor = resultExecutingContext.ActionDescriptor, - resultExecutingContext = resultExecutingContext, - filter = filter - }); + Diagnostics.BeforeOnResultExecution.EventName, + new BeforeOnResultExecution( + resultExecutingContext.ActionDescriptor, + resultExecutingContext, + filter + )); } } @@ -808,16 +786,15 @@ public static void AfterOnResultExecution( 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( - "Microsoft.AspNetCore.Mvc.AfterOnResultExecution", - new - { - actionDescriptor = resultExecutedContext.ActionDescriptor, - resultExecutedContext = resultExecutedContext, - filter = filter - }); + Diagnostics.AfterOnResultExecution.EventName, + new AfterOnResultExecution( + resultExecutedContext.ActionDescriptor, + resultExecutedContext, + filter + )); } } @@ -839,16 +816,15 @@ public static void BeforeOnResultExecuting( 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( - "Microsoft.AspNetCore.Mvc.BeforeOnResultExecuting", - new - { - actionDescriptor = resultExecutingContext.ActionDescriptor, - resultExecutingContext = resultExecutingContext, - filter = filter - }); + Diagnostics.BeforeOnResultExecuting.EventName, + new BeforeOnResultExecuting( + resultExecutingContext.ActionDescriptor, + resultExecutingContext, + filter + )); } } @@ -870,16 +846,15 @@ public static void AfterOnResultExecuting( 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( - "Microsoft.AspNetCore.Mvc.AfterOnResultExecuting", - new - { - actionDescriptor = resultExecutingContext.ActionDescriptor, - resultExecutingContext = resultExecutingContext, - filter = filter - }); + Diagnostics.AfterOnResultExecuting.EventName, + new AfterOnResultExecuting( + resultExecutingContext.ActionDescriptor, + resultExecutingContext, + filter + )); } } @@ -901,16 +876,15 @@ public static void BeforeOnResultExecuted( 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( - "Microsoft.AspNetCore.Mvc.BeforeOnResultExecuted", - new - { - actionDescriptor = resultExecutedContext.ActionDescriptor, - resultExecutedContext = resultExecutedContext, - filter = filter - }); + Diagnostics.BeforeOnResultExecuted.EventName, + new BeforeOnResultExecuted( + resultExecutedContext.ActionDescriptor, + resultExecutedContext, + filter + )); } } @@ -932,16 +906,15 @@ public static void AfterOnResultExecuted( 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( - "Microsoft.AspNetCore.Mvc.AfterOnResultExecuted", - new - { - actionDescriptor = resultExecutedContext.ActionDescriptor, - resultExecutedContext = resultExecutedContext, - filter = filter - }); + Diagnostics.AfterOnResultExecuted.EventName, + new AfterOnResultExecuted( + resultExecutedContext.ActionDescriptor, + resultExecutedContext, + filter + )); } } @@ -963,11 +936,11 @@ public static void BeforeActionResult( 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( - "Microsoft.AspNetCore.Mvc.BeforeActionResult", - new { actionContext = actionContext, result = result }); + Diagnostics.BeforeActionResult.EventName, + new BeforeActionResult(actionContext, result)); } } @@ -989,11 +962,11 @@ public static void AfterActionResult( 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( - "Microsoft.AspNetCore.Mvc.AfterActionResult", - new { actionContext = actionContext, result = result }); + Diagnostics.AfterActionResult.EventName, + new AfterActionResult(actionContext, result)); } } } diff --git a/src/Mvc/Mvc.Razor/ref/Microsoft.AspNetCore.Mvc.Razor.netcoreapp3.0.cs b/src/Mvc/Mvc.Razor/ref/Microsoft.AspNetCore.Mvc.Razor.netcoreapp3.0.cs index 576821fd5b4b..289b37ab2723 100644 --- a/src/Mvc/Mvc.Razor/ref/Microsoft.AspNetCore.Mvc.Razor.netcoreapp3.0.cs +++ b/src/Mvc/Mvc.Razor/ref/Microsoft.AspNetCore.Mvc.Razor.netcoreapp3.0.cs @@ -21,6 +21,31 @@ public partial interface IRazorCompiledItemProvider System.Collections.Generic.IEnumerable 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 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 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 { public partial class HelperResult : Microsoft.AspNetCore.Html.IHtmlContent diff --git a/src/Mvc/Mvc.Razor/src/Diagnostics/MvcDiagnostics.cs b/src/Mvc/Mvc.Razor/src/Diagnostics/MvcDiagnostics.cs new file mode 100644 index 000000000000..d87b9709ad25 --- /dev/null +++ b/src/Mvc/Mvc.Razor/src/Diagnostics/MvcDiagnostics.cs @@ -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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(Page), Page), + 1 => new KeyValuePair(nameof(ViewContext), ViewContext), + 2 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 3 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(Page), Page), + 1 => new KeyValuePair(nameof(ViewContext), ViewContext), + 2 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 3 => new KeyValuePair(nameof(HttpContext), HttpContext), + _ => throw new IndexOutOfRangeException(nameof(index)) + }; + } +} \ No newline at end of file diff --git a/src/Mvc/Mvc.Razor/src/MvcRazorDiagnosticSourceExtensions.cs b/src/Mvc/Mvc.Razor/src/MvcRazorDiagnosticListenerExtensions.cs similarity index 62% rename from src/Mvc/Mvc.Razor/src/MvcRazorDiagnosticSourceExtensions.cs rename to src/Mvc/Mvc.Razor/src/MvcRazorDiagnosticListenerExtensions.cs index f0479ef14301..aff60a929826 100644 --- a/src/Mvc/Mvc.Razor/src/MvcRazorDiagnosticSourceExtensions.cs +++ b/src/Mvc/Mvc.Razor/src/MvcRazorDiagnosticListenerExtensions.cs @@ -3,10 +3,12 @@ using System.Diagnostics; using Microsoft.AspNetCore.Mvc.Rendering; +using Microsoft.AspNetCore.Mvc.Diagnostics; +using Microsoft.AspNetCore.Http; namespace Microsoft.AspNetCore.Mvc.Razor { - internal static class MvcRazorDiagnosticSourceExtensions + internal static class MvcRazorDiagnosticListenerExtensions { public static void BeforeViewPage( this DiagnosticListener diagnosticListener, @@ -25,17 +27,16 @@ private static void BeforeViewPageImpl( IRazorPage page, ViewContext viewContext) { - if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.Razor.BeforeViewPage")) + if (diagnosticListener.IsEnabled(Diagnostics.BeforeViewPage.EventName)) { diagnosticListener.Write( - "Microsoft.AspNetCore.Mvc.Razor.BeforeViewPage", - new - { - page = page, - viewContext = viewContext, - actionDescriptor = viewContext.ActionDescriptor, - httpContext = viewContext.HttpContext, - }); + Diagnostics.BeforeViewPage.EventName, + new BeforeViewPage( + page, + viewContext, + viewContext.ActionDescriptor, + viewContext.HttpContext + )); } } @@ -56,18 +57,17 @@ private static void AfterViewPageImpl( IRazorPage page, ViewContext viewContext) { - if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.Razor.AfterViewPage")) + if (diagnosticListener.IsEnabled(Diagnostics.AfterViewPage.EventName)) { diagnosticListener.Write( - "Microsoft.AspNetCore.Mvc.Razor.AfterViewPage", - new - { - page = page, - viewContext = viewContext, - actionDescriptor = viewContext.ActionDescriptor, - httpContext = viewContext.HttpContext, - }); + Diagnostics.AfterViewPage.EventName, + new AfterViewPage( + page, + viewContext, + viewContext.ActionDescriptor, + viewContext.HttpContext + )); } } } -} +} \ No newline at end of file diff --git a/src/Mvc/Mvc.Razor/src/RazorPage.cs b/src/Mvc/Mvc.Razor/src/RazorPage.cs index 53fd192c241d..be763a3d705f 100644 --- a/src/Mvc/Mvc.Razor/src/RazorPage.cs +++ b/src/Mvc/Mvc.Razor/src/RazorPage.cs @@ -276,37 +276,12 @@ public override void EnsureRenderedBodyOrSections() public override void BeginContext(int position, int length, bool isLiteral) { - const string BeginContextEvent = "Microsoft.AspNetCore.Mvc.Razor.BeginInstrumentationContext"; - - if (DiagnosticSource?.IsEnabled(BeginContextEvent) == true) - { - DiagnosticSource.Write( - BeginContextEvent, - new - { - httpContext = Context, - path = Path, - position = position, - length = length, - isLiteral = isLiteral, - }); - } + // noop } public override void EndContext() { - const string EndContextEvent = "Microsoft.AspNetCore.Mvc.Razor.EndInstrumentationContext"; - - if (DiagnosticSource?.IsEnabled(EndContextEvent) == true) - { - DiagnosticSource.Write( - EndContextEvent, - new - { - httpContext = Context, - path = Path, - }); - } + // noop } private void EnsureMethodCanBeInvoked(string methodName) diff --git a/src/Mvc/Mvc.Razor/test/RazorPageActivatorTest.cs b/src/Mvc/Mvc.Razor/test/RazorPageActivatorTest.cs index f4e3a8d97ad8..da3f6ceccbbf 100644 --- a/src/Mvc/Mvc.Razor/test/RazorPageActivatorTest.cs +++ b/src/Mvc/Mvc.Razor/test/RazorPageActivatorTest.cs @@ -26,7 +26,7 @@ public class RazorPageActivatorTest { public RazorPageActivatorTest() { - DiagnosticSource = new DiagnosticListener("Microsoft.AspNetCore"); + DiagnosticListener = new DiagnosticListener("Microsoft.AspNetCore"); HtmlEncoder = new HtmlTestEncoder(); JsonHelper = Mock.Of(); MetadataProvider = new EmptyModelMetadataProvider(); @@ -34,7 +34,7 @@ public RazorPageActivatorTest() UrlHelperFactory = new UrlHelperFactory(); } - private DiagnosticSource DiagnosticSource { get; } + private DiagnosticListener DiagnosticListener { get; } private HtmlEncoder HtmlEncoder { get; } @@ -62,7 +62,7 @@ public void Activate_ContextualizesServices_AndSetsProperties_OnPage() activator.Activate(instance, viewContext); // Assert - Assert.Same(DiagnosticSource, instance.DiagnosticSource); + Assert.Same(DiagnosticListener, instance.DiagnosticSource); Assert.Same(HtmlEncoder, instance.HtmlEncoder); Assert.Same(JsonHelper, instance.Json); Assert.Same(urlHelper, instance.Url); @@ -97,7 +97,7 @@ public void Activate_ContextualizesServices_AndSetsProperties_OnPageWithoutModel activator.Activate(instance, viewContext); // Assert - Assert.Same(DiagnosticSource, instance.DiagnosticSource); + Assert.Same(DiagnosticListener, instance.DiagnosticSource); Assert.Same(HtmlEncoder, instance.HtmlEncoder); // When we don't have a model property, the activator will just leave ViewData alone. @@ -124,7 +124,7 @@ public void Activate_InstantiatesNewViewDataDictionaryType_IfTheTypeDoesNotMatch activator.Activate(instance, viewContext); // Assert - Assert.Same(DiagnosticSource, instance.DiagnosticSource); + Assert.Same(DiagnosticListener, instance.DiagnosticSource); Assert.Same(HtmlEncoder, instance.HtmlEncoder); Assert.Same(JsonHelper, instance.Json); Assert.Same(urlHelper, instance.Url); @@ -229,7 +229,7 @@ public void GetOrAddCacheEntry_VariesByModelType_IfPageIsModelTypeProvider() 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) diff --git a/src/Mvc/Mvc.Razor/test/RazorPageTest.cs b/src/Mvc/Mvc.Razor/test/RazorPageTest.cs index 8475c8a2fcdc..8b0ffc087568 100644 --- a/src/Mvc/Mvc.Razor/test/RazorPageTest.cs +++ b/src/Mvc/Mvc.Razor/test/RazorPageTest.cs @@ -948,216 +948,6 @@ public async Task FlushAsync_ReturnsEmptyHtmlString() 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 assertStartEvent = data => - { - var beginEvent = Assert.IsType(data); - Assert.NotNull(beginEvent.HttpContext); - Assert.Equal(path, beginEvent.Path); - - return beginEvent; - }; - - Action assertEndEvent = data => - { - var endEvent = Assert.IsType(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 assertStartEvent = data => - { - var beginEvent = Assert.IsType(data); - Assert.NotNull(beginEvent.HttpContext); - Assert.Equal(path, beginEvent.Path); - - return beginEvent; - }; - - Action assertEndEvent = data => - { - var endEvent = Assert.IsType(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 assertStartEvent = data => - { - var beginEvent = Assert.IsType(data); - Assert.NotNull(beginEvent.HttpContext); - Assert.Equal(path, beginEvent.Path); - - return beginEvent; - }; - - Action assertEndEvent = data => - { - var endEvent = Assert.IsType(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 { get diff --git a/src/Mvc/Mvc.RazorPages/ref/Microsoft.AspNetCore.Mvc.RazorPages.netcoreapp3.0.cs b/src/Mvc/Mvc.RazorPages/ref/Microsoft.AspNetCore.Mvc.RazorPages.netcoreapp3.0.cs index 247bcbabcd23..dbd9d6fcb792 100644 --- a/src/Mvc/Mvc.RazorPages/ref/Microsoft.AspNetCore.Mvc.RazorPages.netcoreapp3.0.cs +++ b/src/Mvc/Mvc.RazorPages/ref/Microsoft.AspNetCore.Mvc.RazorPages.netcoreapp3.0.cs @@ -143,6 +143,132 @@ public void Apply(Microsoft.AspNetCore.Mvc.ApplicationModels.PageRouteModel mode 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 this[int index] { get { throw null; } } + } +} namespace Microsoft.AspNetCore.Mvc.Filters { public partial interface IAsyncPageFilter : Microsoft.AspNetCore.Mvc.Filters.IFilterMetadata diff --git a/src/Mvc/Mvc.RazorPages/src/Diagnostics/MvcDiagnostics.cs b/src/Mvc/Mvc.RazorPages/src/Diagnostics/MvcDiagnostics.cs new file mode 100644 index 000000000000..78285b68c4a8 --- /dev/null +++ b/src/Mvc/Mvc.RazorPages/src/Diagnostics/MvcDiagnostics.cs @@ -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 arguments, HandlerMethodDescriptor handlerMethodDescriptor, object instance) + { + ActionContext = actionContext; + Arguments = arguments; + HandlerMethodDescriptor = handlerMethodDescriptor; + Instance = instance; + } + + public ActionContext ActionContext { get; } + public IReadOnlyDictionary Arguments { get; } + public HandlerMethodDescriptor HandlerMethodDescriptor { get; } + public object Instance { get; } + + protected override int Count => 4; + + protected override KeyValuePair this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionContext), ActionContext), + 1 => new KeyValuePair(nameof(Arguments), Arguments), + 2 => new KeyValuePair(nameof(HandlerMethodDescriptor), HandlerMethodDescriptor), + 3 => new KeyValuePair(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 arguments, HandlerMethodDescriptor handlerMethodDescriptor, object instance, IActionResult result) + { + ActionContext = actionContext; + Arguments = arguments; + HandlerMethodDescriptor = handlerMethodDescriptor; + Instance = instance; + Result = result; + } + + public ActionContext ActionContext { get; } + public IReadOnlyDictionary Arguments { get; } + public HandlerMethodDescriptor HandlerMethodDescriptor { get; } + public object Instance { get; } + public IActionResult Result { get; } + + protected override int Count => 5; + + protected override KeyValuePair this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionContext), ActionContext), + 1 => new KeyValuePair(nameof(Arguments), Arguments), + 2 => new KeyValuePair(nameof(HandlerMethodDescriptor), HandlerMethodDescriptor), + 3 => new KeyValuePair(nameof(Instance), Instance), + 4 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(HandlerExecutionContext), HandlerExecutionContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(HandlerExecutedContext), HandlerExecutedContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(HandlerExecutingContext), HandlerExecutingContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(HandlerExecutingContext), HandlerExecutingContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(HandlerExecutedContext), HandlerExecutedContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(HandlerExecutedContext), HandlerExecutedContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(HandlerSelectedContext), HandlerSelectedContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(HandlerSelectedContext), HandlerSelectedContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(HandlerSelectedContext), HandlerSelectedContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(HandlerSelectedContext), HandlerSelectedContext), + 2 => new KeyValuePair(nameof(Filter), Filter), + _ => throw new IndexOutOfRangeException(nameof(index)) + }; + } +} \ No newline at end of file diff --git a/src/Mvc/Mvc.RazorPages/src/MvcRazorPagesDiagnosticSourceExtensions.cs b/src/Mvc/Mvc.RazorPages/src/MvcRazorPagesDiagnosticListenerExtensions.cs similarity index 66% rename from src/Mvc/Mvc.RazorPages/src/MvcRazorPagesDiagnosticSourceExtensions.cs rename to src/Mvc/Mvc.RazorPages/src/MvcRazorPagesDiagnosticListenerExtensions.cs index 5747c9828fb4..f96ec244bc26 100644 --- a/src/Mvc/Mvc.RazorPages/src/MvcRazorPagesDiagnosticSourceExtensions.cs +++ b/src/Mvc/Mvc.RazorPages/src/MvcRazorPagesDiagnosticListenerExtensions.cs @@ -5,16 +5,17 @@ using System.Diagnostics; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure; +using Microsoft.AspNetCore.Mvc.Diagnostics; namespace Microsoft.AspNetCore.Mvc.RazorPages { - internal static class MvcRazorPagesDiagnosticSourceExtensions + internal static class MvcRazorPagesDiagnosticListenerExtensions { public static void BeforeHandlerMethod( this DiagnosticListener diagnosticListener, ActionContext actionContext, HandlerMethodDescriptor handlerMethodDescriptor, - IDictionary arguments, + IReadOnlyDictionary arguments, object instance) { Debug.Assert(diagnosticListener != null); @@ -30,19 +31,18 @@ public static void BeforeHandlerMethod( } } - private static void BeforeHandlerMethodImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, HandlerMethodDescriptor handlerMethodDescriptor, IDictionary arguments, object instance) + private static void BeforeHandlerMethodImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, HandlerMethodDescriptor handlerMethodDescriptor, IReadOnlyDictionary arguments, object instance) { - if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeHandlerMethod")) + if (diagnosticListener.IsEnabled(Diagnostics.BeforeHandlerMethod.EventName)) { diagnosticListener.Write( - "Microsoft.AspNetCore.Mvc.BeforeHandlerMethod", - new - { - actionContext = actionContext, - arguments = arguments, - handlerMethodDescriptor = handlerMethodDescriptor, - instance = instance, - }); + Diagnostics.BeforeHandlerMethod.EventName, + new BeforeHandlerMethod( + actionContext, + arguments, + handlerMethodDescriptor, + instance + )); } } @@ -50,7 +50,7 @@ public static void AfterHandlerMethod( this DiagnosticListener diagnosticListener, ActionContext actionContext, HandlerMethodDescriptor handlerMethodDescriptor, - IDictionary arguments, + IReadOnlyDictionary arguments, object instance, IActionResult result) { @@ -67,20 +67,19 @@ public static void AfterHandlerMethod( } } - private static void AfterHandlerMethodImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, HandlerMethodDescriptor handlerMethodDescriptor, IDictionary arguments, object instance, IActionResult result) + private static void AfterHandlerMethodImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, HandlerMethodDescriptor handlerMethodDescriptor, IReadOnlyDictionary arguments, object instance, IActionResult result) { - if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterHandlerMethod")) + if (diagnosticListener.IsEnabled(Diagnostics.AfterHandlerMethod.EventName)) { diagnosticListener.Write( - "Microsoft.AspNetCore.Mvc.AfterHandlerMethod", - new - { - actionContext = actionContext, - arguments = arguments, - handlerMethodDescriptor = handlerMethodDescriptor, - instance = instance, - result = result - }); + Diagnostics.AfterHandlerMethod.EventName, + new AfterHandlerMethod( + actionContext, + arguments, + handlerMethodDescriptor, + instance, + result + )); } } @@ -102,16 +101,15 @@ public static void BeforeOnPageHandlerExecution( 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( - "Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecution", - new - { - actionDescriptor = handlerExecutionContext.ActionDescriptor, - handlerExecutionContext = handlerExecutionContext, - filter = filter - }); + Diagnostics.BeforeOnPageHandlerExecution.EventName, + new BeforeOnPageHandlerExecution( + handlerExecutionContext.ActionDescriptor, + handlerExecutionContext, + filter + )); } } @@ -133,16 +131,15 @@ public static void AfterOnPageHandlerExecution( 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( - "Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecution", - new - { - actionDescriptor = handlerExecutedContext.ActionDescriptor, - handlerExecutedContext = handlerExecutedContext, - filter = filter - }); + Diagnostics.AfterOnPageHandlerExecution.EventName, + new AfterOnPageHandlerExecution( + handlerExecutedContext.ActionDescriptor, + handlerExecutedContext, + filter + )); } } @@ -164,16 +161,15 @@ public static void BeforeOnPageHandlerExecuting( 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( - "Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecuting", - new - { - actionDescriptor = handlerExecutingContext.ActionDescriptor, - handlerExecutingContext = handlerExecutingContext, - filter = filter - }); + Diagnostics.BeforeOnPageHandlerExecuting.EventName, + new BeforeOnPageHandlerExecuting( + handlerExecutingContext.ActionDescriptor, + handlerExecutingContext, + filter + )); } } @@ -195,16 +191,15 @@ public static void AfterOnPageHandlerExecuting( 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( - "Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecuting", - new - { - actionDescriptor = handlerExecutingContext.ActionDescriptor, - handlerExecutingContext = handlerExecutingContext, - filter = filter - }); + Diagnostics.AfterOnPageHandlerExecuting.EventName, + new AfterOnPageHandlerExecuting( + handlerExecutingContext.ActionDescriptor, + handlerExecutingContext, + filter + )); } } @@ -226,16 +221,15 @@ public static void BeforeOnPageHandlerExecuted( 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( - "Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecuted", - new - { - actionDescriptor = handlerExecutedContext.ActionDescriptor, - handlerExecutedContext = handlerExecutedContext, - filter = filter - }); + Diagnostics.BeforeOnPageHandlerExecuted.EventName, + new BeforeOnPageHandlerExecuted( + handlerExecutedContext.ActionDescriptor, + handlerExecutedContext, + filter + )); } } @@ -257,16 +251,15 @@ public static void AfterOnPageHandlerExecuted( 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( - "Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecuted", - new - { - actionDescriptor = handlerExecutedContext.ActionDescriptor, - handlerExecutedContext = handlerExecutedContext, - filter = filter - }); + Diagnostics.AfterOnPageHandlerExecuted.EventName, + new AfterOnPageHandlerExecuted( + handlerExecutedContext.ActionDescriptor, + handlerExecutedContext, + filter + )); } } @@ -288,16 +281,15 @@ public static void BeforeOnPageHandlerSelection( 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( - "Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerSelection", - new - { - actionDescriptor = handlerSelectedContext.ActionDescriptor, - handlerSelectedContext = handlerSelectedContext, - filter = filter - }); + Diagnostics.BeforeOnPageHandlerSelection.EventName, + new BeforeOnPageHandlerSelection( + handlerSelectedContext.ActionDescriptor, + handlerSelectedContext, + filter + )); } } @@ -319,16 +311,15 @@ public static void AfterOnPageHandlerSelection( 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( - "Microsoft.AspNetCore.Mvc.AfterOnPageHandlerSelection", - new - { - actionDescriptor = handlerSelectedContext.ActionDescriptor, - handlerSelectedContext = handlerSelectedContext, - filter = filter - }); + Diagnostics.AfterOnPageHandlerSelection.EventName, + new AfterOnPageHandlerSelection( + handlerSelectedContext.ActionDescriptor, + handlerSelectedContext, + filter + )); } } @@ -350,16 +341,15 @@ public static void BeforeOnPageHandlerSelected( 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( - "Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerSelected", - new - { - actionDescriptor = handlerSelectedContext.ActionDescriptor, - handlerSelectedContext = handlerSelectedContext, - filter = filter - }); + Diagnostics.BeforeOnPageHandlerSelected.EventName, + new BeforeOnPageHandlerSelected( + handlerSelectedContext.ActionDescriptor, + handlerSelectedContext, + filter + )); } } @@ -381,16 +371,15 @@ public static void AfterOnPageHandlerSelected( 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( - "Microsoft.AspNetCore.Mvc.AfterOnPageHandlerSelected", - new - { - actionDescriptor = handlerSelectedContext.ActionDescriptor, - handlerSelectedContext = handlerSelectedContext, - filter = filter - }); + Diagnostics.AfterOnPageHandlerSelected.EventName, + new AfterOnPageHandlerSelected( + handlerSelectedContext.ActionDescriptor, + handlerSelectedContext, + filter + )); } } } diff --git a/src/Mvc/Mvc.RazorPages/src/PageBase.cs b/src/Mvc/Mvc.RazorPages/src/PageBase.cs index 1d43071cf740..0ae4993b35d2 100644 --- a/src/Mvc/Mvc.RazorPages/src/PageBase.cs +++ b/src/Mvc/Mvc.RazorPages/src/PageBase.cs @@ -110,38 +110,13 @@ public override void EnsureRenderedBodyOrSections() /// public override void BeginContext(int position, int length, bool isLiteral) { - const string BeginContextEvent = "Microsoft.AspNetCore.Mvc.Razor.BeginInstrumentationContext"; - - if (DiagnosticSource?.IsEnabled(BeginContextEvent) == true) - { - DiagnosticSource.Write( - BeginContextEvent, - new - { - httpContext = ViewContext, - path = Path, - position = position, - length = length, - isLiteral = isLiteral, - }); - } + // noop } /// public override void EndContext() { - const string EndContextEvent = "Microsoft.AspNetCore.Mvc.Razor.EndInstrumentationContext"; - - if (DiagnosticSource?.IsEnabled(EndContextEvent) == true) - { - DiagnosticSource.Write( - EndContextEvent, - new - { - httpContext = ViewContext, - path = Path, - }); - } + // noop } /// diff --git a/src/Mvc/Mvc.ViewFeatures/ref/Microsoft.AspNetCore.Mvc.ViewFeatures.netcoreapp3.0.cs b/src/Mvc/Mvc.ViewFeatures/ref/Microsoft.AspNetCore.Mvc.ViewFeatures.netcoreapp3.0.cs index ad98c18e9ace..945609c56031 100644 --- a/src/Mvc/Mvc.ViewFeatures/ref/Microsoft.AspNetCore.Mvc.ViewFeatures.netcoreapp3.0.cs +++ b/src/Mvc/Mvc.ViewFeatures/ref/Microsoft.AspNetCore.Mvc.ViewFeatures.netcoreapp3.0.cs @@ -213,6 +213,92 @@ public ViewResult() { } 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 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 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 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 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 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 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 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 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 this[int index] { get { throw null; } } + public Microsoft.AspNetCore.Mvc.ActionResult Result { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } } + public System.Collections.Generic.IEnumerable SearchedLocations { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } } + public string ViewName { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } } + } +} namespace Microsoft.AspNetCore.Mvc.ModelBinding { public static partial class ModelStateDictionaryExtensions @@ -1286,7 +1372,7 @@ public partial class ViewExecutor public static readonly string DefaultContentType; protected ViewExecutor(Microsoft.AspNetCore.Mvc.Infrastructure.IHttpResponseStreamWriterFactory writerFactory, Microsoft.AspNetCore.Mvc.ViewEngines.ICompositeViewEngine viewEngine, System.Diagnostics.DiagnosticListener diagnosticListener) { } public ViewExecutor(Microsoft.Extensions.Options.IOptions 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.ViewFeatures.ITempDataDictionaryFactory TempDataFactory { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } } protected Microsoft.AspNetCore.Mvc.ViewEngines.IViewEngine ViewEngine { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } } diff --git a/src/Mvc/Mvc.ViewFeatures/src/Diagnostics/MvcDiagnostics.cs b/src/Mvc/Mvc.ViewFeatures/src/Diagnostics/MvcDiagnostics.cs new file mode 100644 index 000000000000..4cccd159b37b --- /dev/null +++ b/src/Mvc/Mvc.ViewFeatures/src/Diagnostics/MvcDiagnostics.cs @@ -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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(ViewComponentContext), ViewComponentContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(ViewComponentContext), ViewComponentContext), + 2 => new KeyValuePair(nameof(ViewComponent), ViewComponent), + 3 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(ViewComponentContext), ViewComponentContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionDescriptor), ActionDescriptor), + 1 => new KeyValuePair(nameof(ViewComponentContext), ViewComponentContext), + 2 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(View), View), + 1 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(View), View), + 1 => new KeyValuePair(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 this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionContext), ActionContext), + 1 => new KeyValuePair(nameof(IsMainPage), IsMainPage), + 2 => new KeyValuePair(nameof(Result), Result), + 3 => new KeyValuePair(nameof(ViewName), ViewName), + 4 => new KeyValuePair(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 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 SearchedLocations { get; } + + protected override int Count => 5; + + protected override KeyValuePair this[int index] => index switch + { + 0 => new KeyValuePair(nameof(ActionContext), ActionContext), + 1 => new KeyValuePair(nameof(IsMainPage), IsMainPage), + 2 => new KeyValuePair(nameof(Result), Result), + 3 => new KeyValuePair(nameof(ViewName), ViewName), + 4 => new KeyValuePair(nameof(SearchedLocations), SearchedLocations), + _ => throw new IndexOutOfRangeException(nameof(index)) + }; + } +} \ No newline at end of file diff --git a/src/Mvc/Mvc.ViewFeatures/src/MvcViewFeaturesDiagnosticSourceExtensions.cs b/src/Mvc/Mvc.ViewFeatures/src/MvcViewFeaturesDiagnosticListenerExtensions.cs similarity index 62% rename from src/Mvc/Mvc.ViewFeatures/src/MvcViewFeaturesDiagnosticSourceExtensions.cs rename to src/Mvc/Mvc.ViewFeatures/src/MvcViewFeaturesDiagnosticListenerExtensions.cs index fa237a7d5dc6..efd7cc8c6c7d 100644 --- a/src/Mvc/Mvc.ViewFeatures/src/MvcViewFeaturesDiagnosticSourceExtensions.cs +++ b/src/Mvc/Mvc.ViewFeatures/src/MvcViewFeaturesDiagnosticListenerExtensions.cs @@ -6,10 +6,11 @@ using Microsoft.AspNetCore.Mvc.Rendering; using Microsoft.AspNetCore.Mvc.ViewComponents; using Microsoft.AspNetCore.Mvc.ViewEngines; +using Microsoft.AspNetCore.Mvc.Diagnostics; namespace Microsoft.AspNetCore.Mvc.ViewFeatures { - internal static class MvcViewFeaturesDiagnosticSourceExtensions + internal static class MvcViewFeaturesDiagnosticListenerExtensions { public static void BeforeViewComponent( this DiagnosticListener diagnosticListener, @@ -25,16 +26,15 @@ public static void BeforeViewComponent( 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( - "Microsoft.AspNetCore.Mvc.BeforeViewComponent", - new - { - actionDescriptor = context.ViewContext.ActionDescriptor, - viewComponentContext = context, - viewComponent = viewComponent - }); + Diagnostics.BeforeViewComponent.EventName, + new BeforeViewComponent( + context.ViewContext.ActionDescriptor, + context, + viewComponent + )); } } @@ -53,17 +53,16 @@ public static void AfterViewComponent( 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( - "Microsoft.AspNetCore.Mvc.AfterViewComponent", - new - { - actionDescriptor = context.ViewContext.ActionDescriptor, - viewComponentContext = context, - viewComponentResult = result, - viewComponent = viewComponent - }); + Diagnostics.AfterViewComponent.EventName, + new AfterViewComponent( + context.ViewContext.ActionDescriptor, + context, + result, + viewComponent + )); } } @@ -81,16 +80,15 @@ public static void ViewComponentBeforeViewExecute( 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( - "Microsoft.AspNetCore.Mvc.ViewComponentBeforeViewExecute", - new - { - actionDescriptor = context.ViewContext.ActionDescriptor, - viewComponentContext = context, - view = view - }); + Diagnostics.ViewComponentBeforeViewExecute.EventName, + new ViewComponentBeforeViewExecute( + context.ViewContext.ActionDescriptor, + context, + view + )); } } @@ -108,16 +106,15 @@ public static void ViewComponentAfterViewExecute( 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( - "Microsoft.AspNetCore.Mvc.ViewComponentAfterViewExecute", - new - { - actionDescriptor = context.ViewContext.ActionDescriptor, - viewComponentContext = context, - view = view - }); + Diagnostics.ViewComponentAfterViewExecute.EventName, + new ViewComponentAfterViewExecute( + context.ViewContext.ActionDescriptor, + context, + view + )); } } @@ -135,11 +132,11 @@ public static void BeforeView( 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( - "Microsoft.AspNetCore.Mvc.BeforeView", - new { view = view, viewContext = viewContext, }); + Diagnostics.BeforeView.EventName, + new BeforeView(view, viewContext)); } } @@ -157,11 +154,11 @@ public static void AfterView( 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( - "Microsoft.AspNetCore.Mvc.AfterView", - new { view = view, viewContext = viewContext, }); + Diagnostics.AfterView.EventName, + new AfterView(view, viewContext)); } } @@ -169,7 +166,7 @@ public static void ViewFound( this DiagnosticListener diagnosticListener, ActionContext actionContext, bool isMainPage, - PartialViewResult viewResult, + ActionResult viewResult, string viewName, IView view) { @@ -180,20 +177,19 @@ public static void ViewFound( } } - 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( - "Microsoft.AspNetCore.Mvc.ViewFound", - new - { - actionContext = actionContext, - isMainPage = isMainPage, - result = viewResult, - viewName = viewName, - view = view, - }); + Diagnostics.ViewFound.EventName, + new ViewFound( + actionContext, + isMainPage, + viewResult, + viewName, + view + )); } } @@ -201,7 +197,7 @@ public static void ViewNotFound( this DiagnosticListener diagnosticListener, ActionContext actionContext, bool isMainPage, - PartialViewResult viewResult, + ActionResult viewResult, string viewName, IEnumerable searchedLocations) { @@ -212,20 +208,19 @@ public static void ViewNotFound( } } - private static void ViewNotFoundImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, bool isMainPage, PartialViewResult viewResult, string viewName, IEnumerable searchedLocations) + private static void ViewNotFoundImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, bool isMainPage, ActionResult viewResult, string viewName, IEnumerable searchedLocations) { - if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.ViewNotFound")) + if (diagnosticListener.IsEnabled(Diagnostics.ViewNotFound.EventName)) { diagnosticListener.Write( - "Microsoft.AspNetCore.Mvc.ViewNotFound", - new - { - actionContext = actionContext, - isMainPage = isMainPage, - result = viewResult, - viewName = viewName, - searchedLocations = searchedLocations, - }); + Diagnostics.ViewNotFound.EventName, + new ViewNotFound( + actionContext, + isMainPage, + viewResult, + viewName, + searchedLocations + )); } } } diff --git a/src/Mvc/Mvc.ViewFeatures/src/PartialViewResultExecutor.cs b/src/Mvc/Mvc.ViewFeatures/src/PartialViewResultExecutor.cs index 18476d70086b..95b68df50660 100644 --- a/src/Mvc/Mvc.ViewFeatures/src/PartialViewResultExecutor.cs +++ b/src/Mvc/Mvc.ViewFeatures/src/PartialViewResultExecutor.cs @@ -108,7 +108,7 @@ public virtual ViewEngineResult FindView(ActionContext actionContext, PartialVie if (result.Success) { - DiagnosticSource.ViewFound( + DiagnosticListener.ViewFound( actionContext, isMainPage: false, viewResult: viewResult, @@ -119,7 +119,7 @@ public virtual ViewEngineResult FindView(ActionContext actionContext, PartialVie } else { - DiagnosticSource.ViewNotFound( + DiagnosticListener.ViewNotFound( actionContext, isMainPage: false, viewResult: viewResult, diff --git a/src/Mvc/Mvc.ViewFeatures/src/ViewExecutor.cs b/src/Mvc/Mvc.ViewFeatures/src/ViewExecutor.cs index 5ac1031f5607..24ca974c2eee 100644 --- a/src/Mvc/Mvc.ViewFeatures/src/ViewExecutor.cs +++ b/src/Mvc/Mvc.ViewFeatures/src/ViewExecutor.cs @@ -32,7 +32,7 @@ public class ViewExecutor /// The . /// The . /// The . - /// The . + /// The . /// The . public ViewExecutor( IOptions viewOptions, @@ -91,13 +91,13 @@ protected ViewExecutor( WriterFactory = writerFactory; ViewEngine = viewEngine; - DiagnosticSource = diagnosticListener; + DiagnosticListener = diagnosticListener; } /// - /// Gets the . + /// Gets the . /// - protected DiagnosticListener DiagnosticSource { get; } + protected DiagnosticListener DiagnosticListener { get; } /// /// Gets the . @@ -242,11 +242,11 @@ protected async Task ExecuteAsync( { viewContext.Writer = writer; - DiagnosticSource.BeforeView(view, viewContext); + DiagnosticListener.BeforeView(view, viewContext); await view.RenderAsync(viewContext); - DiagnosticSource.AfterView(view, viewContext); + DiagnosticListener.AfterView(view, viewContext); } finally { diff --git a/src/Mvc/Mvc.ViewFeatures/src/ViewResultExecutor.cs b/src/Mvc/Mvc.ViewFeatures/src/ViewResultExecutor.cs index 8cc09aac3c7b..69b8750e2fd6 100644 --- a/src/Mvc/Mvc.ViewFeatures/src/ViewResultExecutor.cs +++ b/src/Mvc/Mvc.ViewFeatures/src/ViewResultExecutor.cs @@ -107,7 +107,7 @@ public virtual ViewEngineResult FindView(ActionContext actionContext, ViewResult } } - if (DiagnosticSource.IsEnabled()) + if (DiagnosticListener.IsEnabled()) { OutputDiagnostics(actionContext, viewResult, viewName, stopwatch, result); } @@ -128,35 +128,21 @@ private void OutputDiagnostics(ActionContext actionContext, ViewResult viewResul { if (result.Success) { - if (DiagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.ViewFound")) - { - DiagnosticSource.Write( - "Microsoft.AspNetCore.Mvc.ViewFound", - new - { - actionContext, - isMainPage = true, - result = viewResult, - viewName, - view = result.View, - }); - } + DiagnosticListener.ViewFound( + actionContext, + isMainPage: true, + viewResult, + viewName, + view: result.View); } else { - if (DiagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.ViewNotFound")) - { - DiagnosticSource.Write( - "Microsoft.AspNetCore.Mvc.ViewNotFound", - new - { - actionContext, - isMainPage = true, - result = viewResult, - viewName, - searchedLocations = result.SearchedLocations - }); - } + DiagnosticListener.ViewNotFound( + actionContext, + isMainPage: true, + viewResult, + viewName, + searchedLocations: result.SearchedLocations); } } diff --git a/src/Mvc/Mvc.ViewFeatures/test/ViewComponentResultTest.cs b/src/Mvc/Mvc.ViewFeatures/test/ViewComponentResultTest.cs index 0eff0f4df05b..4dbf5e20d75d 100644 --- a/src/Mvc/Mvc.ViewFeatures/test/ViewComponentResultTest.cs +++ b/src/Mvc/Mvc.ViewFeatures/test/ViewComponentResultTest.cs @@ -264,7 +264,7 @@ public async Task ExecuteResultAsync_ExecutesAsyncViewComponent() } [Fact] - public async Task ExecuteResultAsync_ExecutesViewComponent_AndWritesDiagnosticSource() + public async Task ExecuteResultAsync_ExecutesViewComponent_AndWritesDiagnosticListener() { // Arrange var methodInfo = typeof(TextViewComponent).GetMethod(nameof(TextViewComponent.Invoke)); diff --git a/src/Mvc/Mvc.ViewFeatures/test/ViewComponents/ViewViewComponentResultTest.cs b/src/Mvc/Mvc.ViewFeatures/test/ViewComponents/ViewViewComponentResultTest.cs index 1f0255c7e81d..dc0f10ed0251 100644 --- a/src/Mvc/Mvc.ViewFeatures/test/ViewComponents/ViewViewComponentResultTest.cs +++ b/src/Mvc/Mvc.ViewFeatures/test/ViewComponents/ViewViewComponentResultTest.cs @@ -102,7 +102,7 @@ public void Execute_ResolvesView_WithDefaultAsViewName() } [Fact] - public void Execute_ResolvesView_AndWritesDiagnosticSource() + public void Execute_ResolvesView_AndWritesDiagnosticListener() { // Arrange var view = new Mock(MockBehavior.Strict);