Mvc 310 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297
  1. commit 2414db256f32a047770326d14d8b0e2afd49ba49
  2. Author: Ben Adams <[email protected]>
  3. Date: Tue Aug 28 14:05:49 2018 -0700
  4. Zero cost(ish) diagnositcs when disabled
  5. Inlinable fast-path check if Diagnositcs is enabled
  6. diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Infrastructure/ControllerActionInvoker.cs b/src/Microsoft.AspNetCore.Mvc.Core/Infrastructure/ControllerActionInvoker.cs
  7. index 448f6b41912..099797fbe84 100644
  8. --- a/src/Microsoft.AspNetCore.Mvc.Core/Infrastructure/ControllerActionInvoker.cs
  9. +++ b/src/Microsoft.AspNetCore.Mvc.Core/Infrastructure/ControllerActionInvoker.cs
  10. @@ -26,12 +26,12 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  11. internal ControllerActionInvoker(
  12. ILogger logger,
  13. - DiagnosticSource diagnosticSource,
  14. + DiagnosticListener diagnosticListener,
  15. IActionResultTypeMapper mapper,
  16. ControllerContext controllerContext,
  17. ControllerActionInvokerCacheEntry cacheEntry,
  18. IFilterMetadata[] filters)
  19. - : base(diagnosticSource, logger, mapper, controllerContext, filters, controllerContext.ValueProviderFactories)
  20. + : base(diagnosticListener, logger, mapper, controllerContext, filters, controllerContext.ValueProviderFactories)
  21. {
  22. if (cacheEntry == null)
  23. {
  24. @@ -114,7 +114,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  25. var filter = (IAsyncActionFilter)state;
  26. var actionExecutingContext = _actionExecutingContext;
  27. - _diagnosticSource.BeforeOnActionExecution(actionExecutingContext, filter);
  28. + _diagnosticListener.BeforeOnActionExecution(actionExecutingContext, filter);
  29. _logger.BeforeExecutingMethodOnFilter(
  30. MvcCoreLoggerExtensions.ActionFilter,
  31. nameof(IAsyncActionFilter.OnActionExecutionAsync),
  32. @@ -152,7 +152,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  33. };
  34. }
  35. - _diagnosticSource.AfterOnActionExecution(_actionExecutedContext, filter);
  36. + _diagnosticListener.AfterOnActionExecution(_actionExecutedContext, filter);
  37. _logger.AfterExecutingMethodOnFilter(
  38. MvcCoreLoggerExtensions.ActionFilter,
  39. nameof(IAsyncActionFilter.OnActionExecutionAsync),
  40. @@ -169,7 +169,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  41. var filter = (IActionFilter)state;
  42. var actionExecutingContext = _actionExecutingContext;
  43. - _diagnosticSource.BeforeOnActionExecuting(actionExecutingContext, filter);
  44. + _diagnosticListener.BeforeOnActionExecuting(actionExecutingContext, filter);
  45. _logger.BeforeExecutingMethodOnFilter(
  46. MvcCoreLoggerExtensions.ActionFilter,
  47. nameof(IActionFilter.OnActionExecuting),
  48. @@ -177,7 +177,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  49. filter.OnActionExecuting(actionExecutingContext);
  50. - _diagnosticSource.AfterOnActionExecuting(actionExecutingContext, filter);
  51. + _diagnosticListener.AfterOnActionExecuting(actionExecutingContext, filter);
  52. _logger.AfterExecutingMethodOnFilter(
  53. MvcCoreLoggerExtensions.ActionFilter,
  54. nameof(IActionFilter.OnActionExecuting),
  55. @@ -219,7 +219,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  56. var filter = (IActionFilter)state;
  57. var actionExecutedContext = _actionExecutedContext;
  58. - _diagnosticSource.BeforeOnActionExecuted(actionExecutedContext, filter);
  59. + _diagnosticListener.BeforeOnActionExecuted(actionExecutedContext, filter);
  60. _logger.BeforeExecutingMethodOnFilter(
  61. MvcCoreLoggerExtensions.ActionFilter,
  62. nameof(IActionFilter.OnActionExecuted),
  63. @@ -227,7 +227,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  64. filter.OnActionExecuted(actionExecutedContext);
  65. - _diagnosticSource.AfterOnActionExecuted(actionExecutedContext, filter);
  66. + _diagnosticListener.AfterOnActionExecuted(actionExecutedContext, filter);
  67. _logger.AfterExecutingMethodOnFilter(
  68. MvcCoreLoggerExtensions.ActionFilter,
  69. nameof(IActionFilter.OnActionExecuted),
  70. @@ -335,13 +335,13 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  71. var actionMethodExecutor = _cacheEntry.ActionMethodExecutor;
  72. var orderedArguments = PrepareArguments(arguments, objectMethodExecutor);
  73. - var diagnosticSource = _diagnosticSource;
  74. + var diagnosticListener = _diagnosticListener;
  75. var logger = _logger;
  76. IActionResult result = null;
  77. try
  78. {
  79. - diagnosticSource.BeforeActionMethod(
  80. + diagnosticListener.BeforeActionMethod(
  81. controllerContext,
  82. arguments,
  83. controller);
  84. @@ -362,7 +362,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  85. }
  86. finally
  87. {
  88. - diagnosticSource.AfterActionMethod(
  89. + diagnosticListener.AfterActionMethod(
  90. controllerContext,
  91. arguments,
  92. controllerContext,
  93. diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Infrastructure/ControllerActionInvokerProvider.cs b/src/Microsoft.AspNetCore.Mvc.Core/Infrastructure/ControllerActionInvokerProvider.cs
  94. index 26862696df6..b05bd104dd2 100644
  95. --- a/src/Microsoft.AspNetCore.Mvc.Core/Infrastructure/ControllerActionInvokerProvider.cs
  96. +++ b/src/Microsoft.AspNetCore.Mvc.Core/Infrastructure/ControllerActionInvokerProvider.cs
  97. @@ -19,21 +19,21 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  98. private readonly IReadOnlyList<IValueProviderFactory> _valueProviderFactories;
  99. private readonly int _maxModelValidationErrors;
  100. private readonly ILogger _logger;
  101. - private readonly DiagnosticSource _diagnosticSource;
  102. + private readonly DiagnosticListener _diagnosticListener;
  103. private readonly IActionResultTypeMapper _mapper;
  104. public ControllerActionInvokerProvider(
  105. ControllerActionInvokerCache controllerActionInvokerCache,
  106. IOptions<MvcOptions> optionsAccessor,
  107. ILoggerFactory loggerFactory,
  108. - DiagnosticSource diagnosticSource,
  109. + DiagnosticListener diagnosticListener,
  110. IActionResultTypeMapper mapper)
  111. {
  112. _controllerActionInvokerCache = controllerActionInvokerCache;
  113. _valueProviderFactories = optionsAccessor.Value.ValueProviderFactories.ToArray();
  114. _maxModelValidationErrors = optionsAccessor.Value.MaxModelValidationErrors;
  115. _logger = loggerFactory.CreateLogger<ControllerActionInvoker>();
  116. - _diagnosticSource = diagnosticSource;
  117. + _diagnosticListener = diagnosticListener;
  118. _mapper = mapper;
  119. }
  120. @@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  121. var invoker = new ControllerActionInvoker(
  122. _logger,
  123. - _diagnosticSource,
  124. + _diagnosticListener,
  125. _mapper,
  126. controllerContext,
  127. cacheResult.cacheEntry,
  128. diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Infrastructure/ResourceInvoker.cs b/src/Microsoft.AspNetCore.Mvc.Core/Infrastructure/ResourceInvoker.cs
  129. index 92a80ef42a2..ff969d90b0b 100644
  130. --- a/src/Microsoft.AspNetCore.Mvc.Core/Infrastructure/ResourceInvoker.cs
  131. +++ b/src/Microsoft.AspNetCore.Mvc.Core/Infrastructure/ResourceInvoker.cs
  132. @@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  133. {
  134. internal abstract class ResourceInvoker
  135. {
  136. - protected readonly DiagnosticSource _diagnosticSource;
  137. + protected readonly DiagnosticListener _diagnosticListener;
  138. protected readonly ILogger _logger;
  139. protected readonly IActionResultTypeMapper _mapper;
  140. protected readonly ActionContext _actionContext;
  141. @@ -37,14 +37,14 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  142. protected object _instance;
  143. public ResourceInvoker(
  144. - DiagnosticSource diagnosticSource,
  145. + DiagnosticListener diagnosticListener,
  146. ILogger logger,
  147. IActionResultTypeMapper mapper,
  148. ActionContext actionContext,
  149. IFilterMetadata[] filters,
  150. IList<IValueProviderFactory> valueProviderFactories)
  151. {
  152. - _diagnosticSource = diagnosticSource ?? throw new ArgumentNullException(nameof(diagnosticSource));
  153. + _diagnosticListener = diagnosticListener ?? throw new ArgumentNullException(nameof(diagnosticListener));
  154. _logger = logger ?? throw new ArgumentNullException(nameof(logger));
  155. _mapper = mapper ?? throw new ArgumentNullException(nameof(mapper));
  156. _actionContext = actionContext ?? throw new ArgumentNullException(nameof(actionContext));
  157. @@ -58,7 +58,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  158. {
  159. try
  160. {
  161. - _diagnosticSource.BeforeAction(
  162. + _diagnosticListener.BeforeAction(
  163. _actionContext.ActionDescriptor,
  164. _actionContext.HttpContext,
  165. _actionContext.RouteData);
  166. @@ -88,7 +88,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  167. }
  168. finally
  169. {
  170. - _diagnosticSource.AfterAction(
  171. + _diagnosticListener.AfterAction(
  172. _actionContext.ActionDescriptor,
  173. _actionContext.HttpContext,
  174. _actionContext.RouteData);
  175. @@ -129,7 +129,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  176. {
  177. var actionContext = _actionContext;
  178. - _diagnosticSource.BeforeActionResult(actionContext, result);
  179. + _diagnosticListener.BeforeActionResult(actionContext, result);
  180. _logger.BeforeExecutingActionResult(result);
  181. try
  182. @@ -138,7 +138,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  183. }
  184. finally
  185. {
  186. - _diagnosticSource.AfterActionResult(actionContext, result);
  187. + _diagnosticListener.AfterActionResult(actionContext, result);
  188. _logger.AfterExecutingActionResult(result);
  189. }
  190. }
  191. @@ -195,7 +195,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  192. var filter = (IAsyncAuthorizationFilter)state;
  193. var authorizationContext = _authorizationContext;
  194. - _diagnosticSource.BeforeOnAuthorizationAsync(authorizationContext, filter);
  195. + _diagnosticListener.BeforeOnAuthorizationAsync(authorizationContext, filter);
  196. _logger.BeforeExecutingMethodOnFilter(
  197. FilterTypeConstants.AuthorizationFilter,
  198. nameof(IAsyncAuthorizationFilter.OnAuthorizationAsync),
  199. @@ -219,7 +219,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  200. var filter = (IAsyncAuthorizationFilter)state;
  201. var authorizationContext = _authorizationContext;
  202. - _diagnosticSource.AfterOnAuthorizationAsync(authorizationContext, filter);
  203. + _diagnosticListener.AfterOnAuthorizationAsync(authorizationContext, filter);
  204. _logger.AfterExecutingMethodOnFilter(
  205. FilterTypeConstants.AuthorizationFilter,
  206. nameof(IAsyncAuthorizationFilter.OnAuthorizationAsync),
  207. @@ -241,7 +241,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  208. var filter = (IAuthorizationFilter)state;
  209. var authorizationContext = _authorizationContext;
  210. - _diagnosticSource.BeforeOnAuthorization(authorizationContext, filter);
  211. + _diagnosticListener.BeforeOnAuthorization(authorizationContext, filter);
  212. _logger.BeforeExecutingMethodOnFilter(
  213. FilterTypeConstants.AuthorizationFilter,
  214. nameof(IAuthorizationFilter.OnAuthorization),
  215. @@ -249,7 +249,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  216. filter.OnAuthorization(authorizationContext);
  217. - _diagnosticSource.AfterOnAuthorization(authorizationContext, filter);
  218. + _diagnosticListener.AfterOnAuthorization(authorizationContext, filter);
  219. _logger.AfterExecutingMethodOnFilter(
  220. FilterTypeConstants.AuthorizationFilter,
  221. nameof(IAuthorizationFilter.OnAuthorization),
  222. @@ -332,7 +332,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  223. var filter = (IAsyncResourceFilter)state;
  224. var resourceExecutingContext = _resourceExecutingContext;
  225. - _diagnosticSource.BeforeOnResourceExecution(resourceExecutingContext, filter);
  226. + _diagnosticListener.BeforeOnResourceExecution(resourceExecutingContext, filter);
  227. _logger.BeforeExecutingMethodOnFilter(
  228. FilterTypeConstants.ResourceFilter,
  229. nameof(IAsyncResourceFilter.OnResourceExecutionAsync),
  230. @@ -363,7 +363,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  231. Result = _resourceExecutingContext.Result,
  232. };
  233. - _diagnosticSource.AfterOnResourceExecution(_resourceExecutedContext, filter);
  234. + _diagnosticListener.AfterOnResourceExecution(_resourceExecutedContext, filter);
  235. _logger.AfterExecutingMethodOnFilter(
  236. FilterTypeConstants.ResourceFilter,
  237. nameof(IAsyncResourceFilter.OnResourceExecutionAsync),
  238. @@ -387,7 +387,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  239. var filter = (IResourceFilter)state;
  240. var resourceExecutingContext = _resourceExecutingContext;
  241. - _diagnosticSource.BeforeOnResourceExecuting(resourceExecutingContext, filter);
  242. + _diagnosticListener.BeforeOnResourceExecuting(resourceExecutingContext, filter);
  243. _logger.BeforeExecutingMethodOnFilter(
  244. FilterTypeConstants.ResourceFilter,
  245. nameof(IResourceFilter.OnResourceExecuting),
  246. @@ -395,7 +395,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  247. filter.OnResourceExecuting(resourceExecutingContext);
  248. - _diagnosticSource.AfterOnResourceExecuting(resourceExecutingContext, filter);
  249. + _diagnosticListener.AfterOnResourceExecuting(resourceExecutingContext, filter);
  250. _logger.AfterExecutingMethodOnFilter(
  251. FilterTypeConstants.ResourceFilter,
  252. nameof(IResourceFilter.OnResourceExecuting),
  253. @@ -431,7 +431,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  254. var filter = (IResourceFilter)state;
  255. var resourceExecutedContext = _resourceExecutedContext;
  256. - _diagnosticSource.BeforeOnResourceExecuted(resourceExecutedContext, filter);
  257. + _diagnosticListener.BeforeOnResourceExecuted(resourceExecutedContext, filter);
  258. _logger.BeforeExecutingMethodOnFilter(
  259. FilterTypeConstants.ResourceFilter,
  260. nameof(IResourceFilter.OnResourceExecuted),
  261. @@ -439,7 +439,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  262. filter.OnResourceExecuted(resourceExecutedContext);
  263. - _diagnosticSource.AfterOnResourceExecuted(resourceExecutedContext, filter);
  264. + _diagnosticListener.AfterOnResourceExecuted(resourceExecutedContext, filter);
  265. _logger.AfterExecutingMethodOnFilter(
  266. FilterTypeConstants.ResourceFilter,
  267. nameof(IResourceFilter.OnResourceExecuted),
  268. @@ -527,7 +527,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  269. // we'll call the filter. Otherwise there's nothing to do.
  270. if (exceptionContext?.Exception != null && !exceptionContext.ExceptionHandled)
  271. {
  272. - _diagnosticSource.BeforeOnExceptionAsync(exceptionContext, filter);
  273. + _diagnosticListener.BeforeOnExceptionAsync(exceptionContext, filter);
  274. _logger.BeforeExecutingMethodOnFilter(
  275. FilterTypeConstants.ExceptionFilter,
  276. nameof(IAsyncExceptionFilter.OnExceptionAsync),
  277. @@ -554,7 +554,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  278. var filter = (IAsyncExceptionFilter)state;
  279. var exceptionContext = _exceptionContext;
  280. - _diagnosticSource.AfterOnExceptionAsync(exceptionContext, filter);
  281. + _diagnosticListener.AfterOnExceptionAsync(exceptionContext, filter);
  282. _logger.AfterExecutingMethodOnFilter(
  283. FilterTypeConstants.ExceptionFilter,
  284. nameof(IAsyncExceptionFilter.OnExceptionAsync),
  285. @@ -594,7 +594,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  286. // we'll call the filter. Otherwise there's nothing to do.
  287. if (exceptionContext?.Exception != null && !exceptionContext.ExceptionHandled)
  288. {
  289. - _diagnosticSource.BeforeOnException(exceptionContext, filter);
  290. + _diagnosticListener.BeforeOnException(exceptionContext, filter);
  291. _logger.BeforeExecutingMethodOnFilter(
  292. FilterTypeConstants.ExceptionFilter,
  293. nameof(IExceptionFilter.OnException),
  294. @@ -602,7 +602,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  295. filter.OnException(exceptionContext);
  296. - _diagnosticSource.AfterOnException(exceptionContext, filter);
  297. + _diagnosticListener.AfterOnException(exceptionContext, filter);
  298. _logger.AfterExecutingMethodOnFilter(
  299. FilterTypeConstants.ExceptionFilter,
  300. nameof(IExceptionFilter.OnException),
  301. @@ -904,7 +904,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  302. var filter = (TFilterAsync)state;
  303. var resultExecutingContext = _resultExecutingContext;
  304. - _diagnosticSource.BeforeOnResultExecution(resultExecutingContext, filter);
  305. + _diagnosticListener.BeforeOnResultExecution(resultExecutingContext, filter);
  306. _logger.BeforeExecutingMethodOnFilter(
  307. resultFilterKind,
  308. nameof(IAsyncResultFilter.OnResultExecutionAsync),
  309. @@ -944,7 +944,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  310. };
  311. }
  312. - _diagnosticSource.AfterOnResultExecution(_resultExecutedContext, filter);
  313. + _diagnosticListener.AfterOnResultExecution(_resultExecutedContext, filter);
  314. _logger.AfterExecutingMethodOnFilter(
  315. resultFilterKind,
  316. nameof(IAsyncResultFilter.OnResultExecutionAsync),
  317. @@ -961,7 +961,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  318. var filter = (TFilter)state;
  319. var resultExecutingContext = _resultExecutingContext;
  320. - _diagnosticSource.BeforeOnResultExecuting(resultExecutingContext, filter);
  321. + _diagnosticListener.BeforeOnResultExecuting(resultExecutingContext, filter);
  322. _logger.BeforeExecutingMethodOnFilter(
  323. resultFilterKind,
  324. nameof(IResultFilter.OnResultExecuting),
  325. @@ -969,7 +969,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  326. filter.OnResultExecuting(resultExecutingContext);
  327. - _diagnosticSource.AfterOnResultExecuting(resultExecutingContext, filter);
  328. + _diagnosticListener.AfterOnResultExecuting(resultExecutingContext, filter);
  329. _logger.AfterExecutingMethodOnFilter(
  330. resultFilterKind,
  331. nameof(IResultFilter.OnResultExecuting),
  332. @@ -1011,7 +1011,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  333. var filter = (TFilter)state;
  334. var resultExecutedContext = _resultExecutedContext;
  335. - _diagnosticSource.BeforeOnResultExecuted(resultExecutedContext, filter);
  336. + _diagnosticListener.BeforeOnResultExecuted(resultExecutedContext, filter);
  337. _logger.BeforeExecutingMethodOnFilter(
  338. resultFilterKind,
  339. nameof(IResultFilter.OnResultExecuted),
  340. @@ -1019,7 +1019,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
  341. filter.OnResultExecuted(resultExecutedContext);
  342. - _diagnosticSource.AfterOnResultExecuted(resultExecutedContext, filter);
  343. + _diagnosticListener.AfterOnResultExecuted(resultExecutedContext, filter);
  344. _logger.AfterExecutingMethodOnFilter(
  345. resultFilterKind,
  346. nameof(IResultFilter.OnResultExecuted),
  347. diff --git a/src/Microsoft.AspNetCore.Mvc.Core/MvcCoreDiagnosticSourceExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Core/MvcCoreDiagnosticSourceExtensions.cs
  348. index 0d67d5eda7e..32085e7da86 100644
  349. --- a/src/Microsoft.AspNetCore.Mvc.Core/MvcCoreDiagnosticSourceExtensions.cs
  350. +++ b/src/Microsoft.AspNetCore.Mvc.Core/MvcCoreDiagnosticSourceExtensions.cs
  351. @@ -16,55 +16,82 @@ namespace Microsoft.AspNetCore.Mvc
  352. internal static class MvcCoreDiagnosticSourceExtensions
  353. {
  354. public static void BeforeAction(
  355. - this DiagnosticSource diagnosticSource,
  356. + this DiagnosticListener diagnosticListener,
  357. ActionDescriptor actionDescriptor,
  358. HttpContext httpContext,
  359. RouteData routeData)
  360. {
  361. - Debug.Assert(diagnosticSource != null);
  362. + Debug.Assert(diagnosticListener != null);
  363. Debug.Assert(actionDescriptor != null);
  364. Debug.Assert(httpContext != null);
  365. Debug.Assert(routeData != null);
  366. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeAction"))
  367. + // Inlinable fast-path check if Diagnositcs is enabled
  368. + if (diagnosticListener.IsEnabled())
  369. {
  370. - diagnosticSource.Write(
  371. + BeforeActionImpl(diagnosticListener, actionDescriptor, httpContext, routeData);
  372. + }
  373. + }
  374. +
  375. + private static void BeforeActionImpl(DiagnosticListener diagnosticListener, ActionDescriptor actionDescriptor, HttpContext httpContext, RouteData routeData)
  376. + {
  377. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeAction"))
  378. + {
  379. + diagnosticListener.Write(
  380. "Microsoft.AspNetCore.Mvc.BeforeAction",
  381. new { actionDescriptor, httpContext = httpContext, routeData = routeData });
  382. }
  383. }
  384. public static void AfterAction(
  385. - this DiagnosticSource diagnosticSource,
  386. + this DiagnosticListener diagnosticListener,
  387. ActionDescriptor actionDescriptor,
  388. HttpContext httpContext,
  389. RouteData routeData)
  390. {
  391. - Debug.Assert(diagnosticSource != null);
  392. + Debug.Assert(diagnosticListener != null);
  393. Debug.Assert(actionDescriptor != null);
  394. Debug.Assert(httpContext != null);
  395. Debug.Assert(routeData != null);
  396. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterAction"))
  397. + // Inlinable fast-path check if Diagnositcs is enabled
  398. + if (diagnosticListener.IsEnabled())
  399. + {
  400. + AfterActionImpl(diagnosticListener, actionDescriptor, httpContext, routeData);
  401. + }
  402. + }
  403. +
  404. + private static void AfterActionImpl(DiagnosticListener diagnosticListener, ActionDescriptor actionDescriptor, HttpContext httpContext, RouteData routeData)
  405. + {
  406. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterAction"))
  407. {
  408. - diagnosticSource.Write(
  409. + diagnosticListener.Write(
  410. "Microsoft.AspNetCore.Mvc.AfterAction",
  411. new { actionDescriptor, httpContext = httpContext, routeData = routeData });
  412. }
  413. }
  414. public static void BeforeOnAuthorizationAsync(
  415. - this DiagnosticSource diagnosticSource,
  416. + this DiagnosticListener diagnosticListener,
  417. AuthorizationFilterContext authorizationContext,
  418. IAsyncAuthorizationFilter filter)
  419. {
  420. - Debug.Assert(diagnosticSource != null);
  421. + Debug.Assert(diagnosticListener != null);
  422. Debug.Assert(authorizationContext != null);
  423. Debug.Assert(filter != null);
  424. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnAuthorization"))
  425. + // Inlinable fast-path check if Diagnositcs is enabled
  426. + if (diagnosticListener.IsEnabled())
  427. {
  428. - diagnosticSource.Write(
  429. + BeforeOnAuthorizationAsyncImpl(diagnosticListener, authorizationContext, filter);
  430. + }
  431. + }
  432. +
  433. + private static void BeforeOnAuthorizationAsyncImpl(DiagnosticListener diagnosticListener, AuthorizationFilterContext authorizationContext, IAsyncAuthorizationFilter filter)
  434. + {
  435. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnAuthorization"))
  436. + {
  437. + diagnosticListener.Write(
  438. "Microsoft.AspNetCore.Mvc.BeforeOnAuthorization",
  439. new
  440. {
  441. @@ -76,17 +103,26 @@ namespace Microsoft.AspNetCore.Mvc
  442. }
  443. public static void AfterOnAuthorizationAsync(
  444. - this DiagnosticSource diagnosticSource,
  445. + this DiagnosticListener diagnosticListener,
  446. AuthorizationFilterContext authorizationContext,
  447. IAsyncAuthorizationFilter filter)
  448. {
  449. - Debug.Assert(diagnosticSource != null);
  450. + Debug.Assert(diagnosticListener != null);
  451. Debug.Assert(authorizationContext != null);
  452. Debug.Assert(filter != null);
  453. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnAuthorization"))
  454. + // Inlinable fast-path check if Diagnositcs is enabled
  455. + if (diagnosticListener.IsEnabled())
  456. + {
  457. + AfterOnAuthorizationAsyncImpl(diagnosticListener, authorizationContext, filter);
  458. + }
  459. + }
  460. +
  461. + private static void AfterOnAuthorizationAsyncImpl(DiagnosticListener diagnosticListener, AuthorizationFilterContext authorizationContext, IAsyncAuthorizationFilter filter)
  462. + {
  463. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnAuthorization"))
  464. {
  465. - diagnosticSource.Write(
  466. + diagnosticListener.Write(
  467. "Microsoft.AspNetCore.Mvc.AfterOnAuthorization",
  468. new
  469. {
  470. @@ -98,17 +134,26 @@ namespace Microsoft.AspNetCore.Mvc
  471. }
  472. public static void BeforeOnAuthorization(
  473. - this DiagnosticSource diagnosticSource,
  474. + this DiagnosticListener diagnosticListener,
  475. AuthorizationFilterContext authorizationContext,
  476. IAuthorizationFilter filter)
  477. {
  478. - Debug.Assert(diagnosticSource != null);
  479. + Debug.Assert(diagnosticListener != null);
  480. Debug.Assert(authorizationContext != null);
  481. Debug.Assert(filter != null);
  482. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnAuthorization"))
  483. + // Inlinable fast-path check if Diagnositcs is enabled
  484. + if (diagnosticListener.IsEnabled())
  485. {
  486. - diagnosticSource.Write(
  487. + BeforeOnAuthorizationImpl(diagnosticListener, authorizationContext, filter);
  488. + }
  489. + }
  490. +
  491. + private static void BeforeOnAuthorizationImpl(DiagnosticListener diagnosticListener, AuthorizationFilterContext authorizationContext, IAuthorizationFilter filter)
  492. + {
  493. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnAuthorization"))
  494. + {
  495. + diagnosticListener.Write(
  496. "Microsoft.AspNetCore.Mvc.BeforeOnAuthorization",
  497. new
  498. {
  499. @@ -120,17 +165,26 @@ namespace Microsoft.AspNetCore.Mvc
  500. }
  501. public static void AfterOnAuthorization(
  502. - this DiagnosticSource diagnosticSource,
  503. + this DiagnosticListener diagnosticListener,
  504. AuthorizationFilterContext authorizationContext,
  505. IAuthorizationFilter filter)
  506. {
  507. - Debug.Assert(diagnosticSource != null);
  508. + Debug.Assert(diagnosticListener != null);
  509. Debug.Assert(authorizationContext != null);
  510. Debug.Assert(filter != null);
  511. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnAuthorization"))
  512. + // Inlinable fast-path check if Diagnositcs is enabled
  513. + if (diagnosticListener.IsEnabled())
  514. + {
  515. + AfterOnAuthorizationImpl(diagnosticListener, authorizationContext, filter);
  516. + }
  517. + }
  518. +
  519. + private static void AfterOnAuthorizationImpl(DiagnosticListener diagnosticListener, AuthorizationFilterContext authorizationContext, IAuthorizationFilter filter)
  520. + {
  521. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnAuthorization"))
  522. {
  523. - diagnosticSource.Write(
  524. + diagnosticListener.Write(
  525. "Microsoft.AspNetCore.Mvc.AfterOnAuthorization",
  526. new
  527. {
  528. @@ -142,17 +196,26 @@ namespace Microsoft.AspNetCore.Mvc
  529. }
  530. public static void BeforeOnResourceExecution(
  531. - this DiagnosticSource diagnosticSource,
  532. + this DiagnosticListener diagnosticListener,
  533. ResourceExecutingContext resourceExecutingContext,
  534. IAsyncResourceFilter filter)
  535. {
  536. - Debug.Assert(diagnosticSource != null);
  537. + Debug.Assert(diagnosticListener != null);
  538. Debug.Assert(resourceExecutingContext != null);
  539. Debug.Assert(filter != null);
  540. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResourceExecution"))
  541. + // Inlinable fast-path check if Diagnositcs is enabled
  542. + if (diagnosticListener.IsEnabled())
  543. {
  544. - diagnosticSource.Write(
  545. + BeforeOnResourceExecutionImpl(diagnosticListener, resourceExecutingContext, filter);
  546. + }
  547. + }
  548. +
  549. + private static void BeforeOnResourceExecutionImpl(DiagnosticListener diagnosticListener, ResourceExecutingContext resourceExecutingContext, IAsyncResourceFilter filter)
  550. + {
  551. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResourceExecution"))
  552. + {
  553. + diagnosticListener.Write(
  554. "Microsoft.AspNetCore.Mvc.BeforeOnResourceExecution",
  555. new
  556. {
  557. @@ -164,17 +227,26 @@ namespace Microsoft.AspNetCore.Mvc
  558. }
  559. public static void AfterOnResourceExecution(
  560. - this DiagnosticSource diagnosticSource,
  561. + this DiagnosticListener diagnosticListener,
  562. ResourceExecutedContext resourceExecutedContext,
  563. IAsyncResourceFilter filter)
  564. {
  565. - Debug.Assert(diagnosticSource != null);
  566. + Debug.Assert(diagnosticListener != null);
  567. Debug.Assert(resourceExecutedContext != null);
  568. Debug.Assert(filter != null);
  569. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResourceExecution"))
  570. + // Inlinable fast-path check if Diagnositcs is enabled
  571. + if (diagnosticListener.IsEnabled())
  572. + {
  573. + AfterOnResourceExecutionImpl(diagnosticListener, resourceExecutedContext, filter);
  574. + }
  575. + }
  576. +
  577. + private static void AfterOnResourceExecutionImpl(DiagnosticListener diagnosticListener, ResourceExecutedContext resourceExecutedContext, IAsyncResourceFilter filter)
  578. + {
  579. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResourceExecution"))
  580. {
  581. - diagnosticSource.Write(
  582. + diagnosticListener.Write(
  583. "Microsoft.AspNetCore.Mvc.AfterOnResourceExecution",
  584. new
  585. {
  586. @@ -186,17 +258,26 @@ namespace Microsoft.AspNetCore.Mvc
  587. }
  588. public static void BeforeOnResourceExecuting(
  589. - this DiagnosticSource diagnosticSource,
  590. + this DiagnosticListener diagnosticListener,
  591. ResourceExecutingContext resourceExecutingContext,
  592. IResourceFilter filter)
  593. {
  594. - Debug.Assert(diagnosticSource != null);
  595. + Debug.Assert(diagnosticListener != null);
  596. Debug.Assert(resourceExecutingContext != null);
  597. Debug.Assert(filter != null);
  598. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResourceExecuting"))
  599. + // Inlinable fast-path check if Diagnositcs is enabled
  600. + if (diagnosticListener.IsEnabled())
  601. {
  602. - diagnosticSource.Write(
  603. + BeforeOnResourceExecutingImpl(diagnosticListener, resourceExecutingContext, filter);
  604. + }
  605. + }
  606. +
  607. + private static void BeforeOnResourceExecutingImpl(DiagnosticListener diagnosticListener, ResourceExecutingContext resourceExecutingContext, IResourceFilter filter)
  608. + {
  609. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResourceExecuting"))
  610. + {
  611. + diagnosticListener.Write(
  612. "Microsoft.AspNetCore.Mvc.BeforeOnResourceExecuting",
  613. new
  614. {
  615. @@ -208,17 +289,26 @@ namespace Microsoft.AspNetCore.Mvc
  616. }
  617. public static void AfterOnResourceExecuting(
  618. - this DiagnosticSource diagnosticSource,
  619. + this DiagnosticListener diagnosticListener,
  620. ResourceExecutingContext resourceExecutingContext,
  621. IResourceFilter filter)
  622. {
  623. - Debug.Assert(diagnosticSource != null);
  624. + Debug.Assert(diagnosticListener != null);
  625. Debug.Assert(resourceExecutingContext != null);
  626. Debug.Assert(filter != null);
  627. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResourceExecuting"))
  628. + // Inlinable fast-path check if Diagnositcs is enabled
  629. + if (diagnosticListener.IsEnabled())
  630. + {
  631. + AfterOnResourceExecutingImpl(diagnosticListener, resourceExecutingContext, filter);
  632. + }
  633. + }
  634. +
  635. + private static void AfterOnResourceExecutingImpl(DiagnosticListener diagnosticListener, ResourceExecutingContext resourceExecutingContext, IResourceFilter filter)
  636. + {
  637. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResourceExecuting"))
  638. {
  639. - diagnosticSource.Write(
  640. + diagnosticListener.Write(
  641. "Microsoft.AspNetCore.Mvc.AfterOnResourceExecuting",
  642. new
  643. {
  644. @@ -230,17 +320,26 @@ namespace Microsoft.AspNetCore.Mvc
  645. }
  646. public static void BeforeOnResourceExecuted(
  647. - this DiagnosticSource diagnosticSource,
  648. + this DiagnosticListener diagnosticListener,
  649. ResourceExecutedContext resourceExecutedContext,
  650. IResourceFilter filter)
  651. {
  652. - Debug.Assert(diagnosticSource != null);
  653. + Debug.Assert(diagnosticListener != null);
  654. Debug.Assert(resourceExecutedContext != null);
  655. Debug.Assert(filter != null);
  656. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResourceExecuted"))
  657. + // Inlinable fast-path check if Diagnositcs is enabled
  658. + if (diagnosticListener.IsEnabled())
  659. {
  660. - diagnosticSource.Write(
  661. + BeforeOnResourceExecutedImpl(diagnosticListener, resourceExecutedContext, filter);
  662. + }
  663. + }
  664. +
  665. + private static void BeforeOnResourceExecutedImpl(DiagnosticListener diagnosticListener, ResourceExecutedContext resourceExecutedContext, IResourceFilter filter)
  666. + {
  667. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResourceExecuted"))
  668. + {
  669. + diagnosticListener.Write(
  670. "Microsoft.AspNetCore.Mvc.BeforeOnResourceExecuted",
  671. new
  672. {
  673. @@ -252,17 +351,26 @@ namespace Microsoft.AspNetCore.Mvc
  674. }
  675. public static void AfterOnResourceExecuted(
  676. - this DiagnosticSource diagnosticSource,
  677. + this DiagnosticListener diagnosticListener,
  678. ResourceExecutedContext resourceExecutedContext,
  679. IResourceFilter filter)
  680. {
  681. - Debug.Assert(diagnosticSource != null);
  682. + Debug.Assert(diagnosticListener != null);
  683. Debug.Assert(resourceExecutedContext != null);
  684. Debug.Assert(filter != null);
  685. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResourceExecuted"))
  686. + // Inlinable fast-path check if Diagnositcs is enabled
  687. + if (diagnosticListener.IsEnabled())
  688. + {
  689. + AfterOnResourceExecutedImpl(diagnosticListener, resourceExecutedContext, filter);
  690. + }
  691. + }
  692. +
  693. + private static void AfterOnResourceExecutedImpl(DiagnosticListener diagnosticListener, ResourceExecutedContext resourceExecutedContext, IResourceFilter filter)
  694. + {
  695. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResourceExecuted"))
  696. {
  697. - diagnosticSource.Write(
  698. + diagnosticListener.Write(
  699. "Microsoft.AspNetCore.Mvc.AfterOnResourceExecuted",
  700. new
  701. {
  702. @@ -274,17 +382,26 @@ namespace Microsoft.AspNetCore.Mvc
  703. }
  704. public static void BeforeOnExceptionAsync(
  705. - this DiagnosticSource diagnosticSource,
  706. + this DiagnosticListener diagnosticListener,
  707. ExceptionContext exceptionContext,
  708. IAsyncExceptionFilter filter)
  709. {
  710. - Debug.Assert(diagnosticSource != null);
  711. + Debug.Assert(diagnosticListener != null);
  712. Debug.Assert(exceptionContext != null);
  713. Debug.Assert(filter != null);
  714. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnException"))
  715. + // Inlinable fast-path check if Diagnositcs is enabled
  716. + if (diagnosticListener.IsEnabled())
  717. {
  718. - diagnosticSource.Write(
  719. + BeforeOnExceptionAsyncImpl(diagnosticListener, exceptionContext, filter);
  720. + }
  721. + }
  722. +
  723. + private static void BeforeOnExceptionAsyncImpl(DiagnosticListener diagnosticListener, ExceptionContext exceptionContext, IAsyncExceptionFilter filter)
  724. + {
  725. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnException"))
  726. + {
  727. + diagnosticListener.Write(
  728. "Microsoft.AspNetCore.Mvc.BeforeOnException",
  729. new
  730. {
  731. @@ -296,17 +413,26 @@ namespace Microsoft.AspNetCore.Mvc
  732. }
  733. public static void AfterOnExceptionAsync(
  734. - this DiagnosticSource diagnosticSource,
  735. + this DiagnosticListener diagnosticListener,
  736. ExceptionContext exceptionContext,
  737. IAsyncExceptionFilter filter)
  738. {
  739. - Debug.Assert(diagnosticSource != null);
  740. + Debug.Assert(diagnosticListener != null);
  741. Debug.Assert(exceptionContext != null);
  742. Debug.Assert(filter != null);
  743. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnException"))
  744. + // Inlinable fast-path check if Diagnositcs is enabled
  745. + if (diagnosticListener.IsEnabled())
  746. + {
  747. + AfterOnExceptionAsyncImpl(diagnosticListener, exceptionContext, filter);
  748. + }
  749. + }
  750. +
  751. + private static void AfterOnExceptionAsyncImpl(DiagnosticListener diagnosticListener, ExceptionContext exceptionContext, IAsyncExceptionFilter filter)
  752. + {
  753. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnException"))
  754. {
  755. - diagnosticSource.Write(
  756. + diagnosticListener.Write(
  757. "Microsoft.AspNetCore.Mvc.AfterOnException",
  758. new
  759. {
  760. @@ -318,17 +444,26 @@ namespace Microsoft.AspNetCore.Mvc
  761. }
  762. public static void BeforeOnException(
  763. - this DiagnosticSource diagnosticSource,
  764. + this DiagnosticListener diagnosticListener,
  765. ExceptionContext exceptionContext,
  766. IExceptionFilter filter)
  767. {
  768. - Debug.Assert(diagnosticSource != null);
  769. + Debug.Assert(diagnosticListener != null);
  770. Debug.Assert(exceptionContext != null);
  771. Debug.Assert(filter != null);
  772. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnException"))
  773. + // Inlinable fast-path check if Diagnositcs is enabled
  774. + if (diagnosticListener.IsEnabled())
  775. {
  776. - diagnosticSource.Write(
  777. + BeforeOnExceptionImpl(diagnosticListener, exceptionContext, filter);
  778. + }
  779. + }
  780. +
  781. + private static void BeforeOnExceptionImpl(DiagnosticListener diagnosticListener, ExceptionContext exceptionContext, IExceptionFilter filter)
  782. + {
  783. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnException"))
  784. + {
  785. + diagnosticListener.Write(
  786. "Microsoft.AspNetCore.Mvc.BeforeOnException",
  787. new
  788. {
  789. @@ -340,17 +475,26 @@ namespace Microsoft.AspNetCore.Mvc
  790. }
  791. public static void AfterOnException(
  792. - this DiagnosticSource diagnosticSource,
  793. + this DiagnosticListener diagnosticListener,
  794. ExceptionContext exceptionContext,
  795. IExceptionFilter filter)
  796. {
  797. - Debug.Assert(diagnosticSource != null);
  798. + Debug.Assert(diagnosticListener != null);
  799. Debug.Assert(exceptionContext != null);
  800. Debug.Assert(filter != null);
  801. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnException"))
  802. + // Inlinable fast-path check if Diagnositcs is enabled
  803. + if (diagnosticListener.IsEnabled())
  804. + {
  805. + AfterOnExceptionImpl(diagnosticListener, exceptionContext, filter);
  806. + }
  807. + }
  808. +
  809. + private static void AfterOnExceptionImpl(DiagnosticListener diagnosticListener, ExceptionContext exceptionContext, IExceptionFilter filter)
  810. + {
  811. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnException"))
  812. {
  813. - diagnosticSource.Write(
  814. + diagnosticListener.Write(
  815. "Microsoft.AspNetCore.Mvc.AfterOnException",
  816. new
  817. {
  818. @@ -362,17 +506,26 @@ namespace Microsoft.AspNetCore.Mvc
  819. }
  820. public static void BeforeOnActionExecution(
  821. - this DiagnosticSource diagnosticSource,
  822. + this DiagnosticListener diagnosticListener,
  823. ActionExecutingContext actionExecutingContext,
  824. IAsyncActionFilter filter)
  825. {
  826. - Debug.Assert(diagnosticSource != null);
  827. + Debug.Assert(diagnosticListener != null);
  828. Debug.Assert(actionExecutingContext != null);
  829. Debug.Assert(filter != null);
  830. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnActionExecution"))
  831. + // Inlinable fast-path check if Diagnositcs is enabled
  832. + if (diagnosticListener.IsEnabled())
  833. {
  834. - diagnosticSource.Write(
  835. + BeforeOnActionExecutionImpl(diagnosticListener, actionExecutingContext, filter);
  836. + }
  837. + }
  838. +
  839. + private static void BeforeOnActionExecutionImpl(DiagnosticListener diagnosticListener, ActionExecutingContext actionExecutingContext, IAsyncActionFilter filter)
  840. + {
  841. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnActionExecution"))
  842. + {
  843. + diagnosticListener.Write(
  844. "Microsoft.AspNetCore.Mvc.BeforeOnActionExecution",
  845. new
  846. {
  847. @@ -384,17 +537,26 @@ namespace Microsoft.AspNetCore.Mvc
  848. }
  849. public static void AfterOnActionExecution(
  850. - this DiagnosticSource diagnosticSource,
  851. + this DiagnosticListener diagnosticListener,
  852. ActionExecutedContext actionExecutedContext,
  853. IAsyncActionFilter filter)
  854. {
  855. - Debug.Assert(diagnosticSource != null);
  856. + Debug.Assert(diagnosticListener != null);
  857. Debug.Assert(actionExecutedContext != null);
  858. Debug.Assert(filter != null);
  859. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnActionExecution"))
  860. + // Inlinable fast-path check if Diagnositcs is enabled
  861. + if (diagnosticListener.IsEnabled())
  862. + {
  863. + AfterOnActionExecutionImpl(diagnosticListener, actionExecutedContext, filter);
  864. + }
  865. + }
  866. +
  867. + private static void AfterOnActionExecutionImpl(DiagnosticListener diagnosticListener, ActionExecutedContext actionExecutedContext, IAsyncActionFilter filter)
  868. + {
  869. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnActionExecution"))
  870. {
  871. - diagnosticSource.Write(
  872. + diagnosticListener.Write(
  873. "Microsoft.AspNetCore.Mvc.AfterOnActionExecution",
  874. new
  875. {
  876. @@ -406,17 +568,26 @@ namespace Microsoft.AspNetCore.Mvc
  877. }
  878. public static void BeforeOnActionExecuting(
  879. - this DiagnosticSource diagnosticSource,
  880. + this DiagnosticListener diagnosticListener,
  881. ActionExecutingContext actionExecutingContext,
  882. IActionFilter filter)
  883. {
  884. - Debug.Assert(diagnosticSource != null);
  885. + Debug.Assert(diagnosticListener != null);
  886. Debug.Assert(actionExecutingContext != null);
  887. Debug.Assert(filter != null);
  888. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnActionExecuting"))
  889. + // Inlinable fast-path check if Diagnositcs is enabled
  890. + if (diagnosticListener.IsEnabled())
  891. {
  892. - diagnosticSource.Write(
  893. + BeforeOnActionExecutingImpl(diagnosticListener, actionExecutingContext, filter);
  894. + }
  895. + }
  896. +
  897. + private static void BeforeOnActionExecutingImpl(DiagnosticListener diagnosticListener, ActionExecutingContext actionExecutingContext, IActionFilter filter)
  898. + {
  899. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnActionExecuting"))
  900. + {
  901. + diagnosticListener.Write(
  902. "Microsoft.AspNetCore.Mvc.BeforeOnActionExecuting",
  903. new
  904. {
  905. @@ -428,17 +599,26 @@ namespace Microsoft.AspNetCore.Mvc
  906. }
  907. public static void AfterOnActionExecuting(
  908. - this DiagnosticSource diagnosticSource,
  909. + this DiagnosticListener diagnosticListener,
  910. ActionExecutingContext actionExecutingContext,
  911. IActionFilter filter)
  912. {
  913. - Debug.Assert(diagnosticSource != null);
  914. + Debug.Assert(diagnosticListener != null);
  915. Debug.Assert(actionExecutingContext != null);
  916. Debug.Assert(filter != null);
  917. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnActionExecuting"))
  918. + // Inlinable fast-path check if Diagnositcs is enabled
  919. + if (diagnosticListener.IsEnabled())
  920. + {
  921. + AfterOnActionExecutingImpl(diagnosticListener, actionExecutingContext, filter);
  922. + }
  923. + }
  924. +
  925. + private static void AfterOnActionExecutingImpl(DiagnosticListener diagnosticListener, ActionExecutingContext actionExecutingContext, IActionFilter filter)
  926. + {
  927. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnActionExecuting"))
  928. {
  929. - diagnosticSource.Write(
  930. + diagnosticListener.Write(
  931. "Microsoft.AspNetCore.Mvc.AfterOnActionExecuting",
  932. new
  933. {
  934. @@ -450,17 +630,26 @@ namespace Microsoft.AspNetCore.Mvc
  935. }
  936. public static void BeforeOnActionExecuted(
  937. - this DiagnosticSource diagnosticSource,
  938. + this DiagnosticListener diagnosticListener,
  939. ActionExecutedContext actionExecutedContext,
  940. IActionFilter filter)
  941. {
  942. - Debug.Assert(diagnosticSource != null);
  943. + Debug.Assert(diagnosticListener != null);
  944. Debug.Assert(actionExecutedContext != null);
  945. Debug.Assert(filter != null);
  946. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnActionExecuted"))
  947. + // Inlinable fast-path check if Diagnositcs is enabled
  948. + if (diagnosticListener.IsEnabled())
  949. {
  950. - diagnosticSource.Write(
  951. + BeforeOnActionExecutedImpl(diagnosticListener, actionExecutedContext, filter);
  952. + }
  953. + }
  954. +
  955. + private static void BeforeOnActionExecutedImpl(DiagnosticListener diagnosticListener, ActionExecutedContext actionExecutedContext, IActionFilter filter)
  956. + {
  957. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnActionExecuted"))
  958. + {
  959. + diagnosticListener.Write(
  960. "Microsoft.AspNetCore.Mvc.BeforeOnActionExecuted",
  961. new
  962. {
  963. @@ -472,17 +661,26 @@ namespace Microsoft.AspNetCore.Mvc
  964. }
  965. public static void AfterOnActionExecuted(
  966. - this DiagnosticSource diagnosticSource,
  967. + this DiagnosticListener diagnosticListener,
  968. ActionExecutedContext actionExecutedContext,
  969. IActionFilter filter)
  970. {
  971. - Debug.Assert(diagnosticSource != null);
  972. + Debug.Assert(diagnosticListener != null);
  973. Debug.Assert(actionExecutedContext != null);
  974. Debug.Assert(filter != null);
  975. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnActionExecuted"))
  976. + // Inlinable fast-path check if Diagnositcs is enabled
  977. + if (diagnosticListener.IsEnabled())
  978. + {
  979. + AfterOnActionExecutedImpl(diagnosticListener, actionExecutedContext, filter);
  980. + }
  981. + }
  982. +
  983. + private static void AfterOnActionExecutedImpl(DiagnosticListener diagnosticListener, ActionExecutedContext actionExecutedContext, IActionFilter filter)
  984. + {
  985. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnActionExecuted"))
  986. {
  987. - diagnosticSource.Write(
  988. + diagnosticListener.Write(
  989. "Microsoft.AspNetCore.Mvc.AfterOnActionExecuted",
  990. new
  991. {
  992. @@ -494,19 +692,28 @@ namespace Microsoft.AspNetCore.Mvc
  993. }
  994. public static void BeforeActionMethod(
  995. - this DiagnosticSource diagnosticSource,
  996. + this DiagnosticListener diagnosticListener,
  997. ActionContext actionContext,
  998. IDictionary<string, object> actionArguments,
  999. object controller)
  1000. {
  1001. - Debug.Assert(diagnosticSource != null);
  1002. + Debug.Assert(diagnosticListener != null);
  1003. Debug.Assert(actionContext != null);
  1004. Debug.Assert(actionArguments != null);
  1005. Debug.Assert(controller != null);
  1006. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeActionMethod"))
  1007. + // Inlinable fast-path check if Diagnositcs is enabled
  1008. + if (diagnosticListener.IsEnabled())
  1009. {
  1010. - diagnosticSource.Write(
  1011. + BeforeActionMethodImpl(diagnosticListener, actionContext, actionArguments, controller);
  1012. + }
  1013. + }
  1014. +
  1015. + private static void BeforeActionMethodImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, IDictionary<string, object> actionArguments, object controller)
  1016. + {
  1017. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeActionMethod"))
  1018. + {
  1019. + diagnosticListener.Write(
  1020. "Microsoft.AspNetCore.Mvc.BeforeActionMethod",
  1021. new
  1022. {
  1023. @@ -518,20 +725,29 @@ namespace Microsoft.AspNetCore.Mvc
  1024. }
  1025. public static void AfterActionMethod(
  1026. - this DiagnosticSource diagnosticSource,
  1027. + this DiagnosticListener diagnosticListener,
  1028. ActionContext actionContext,
  1029. IDictionary<string, object> actionArguments,
  1030. object controller,
  1031. IActionResult result)
  1032. {
  1033. - Debug.Assert(diagnosticSource != null);
  1034. + Debug.Assert(diagnosticListener != null);
  1035. Debug.Assert(actionContext != null);
  1036. Debug.Assert(actionArguments != null);
  1037. Debug.Assert(controller != null);
  1038. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterActionMethod"))
  1039. + // Inlinable fast-path check if Diagnositcs is enabled
  1040. + if (diagnosticListener.IsEnabled())
  1041. + {
  1042. + AfterActionMethodImpl(diagnosticListener, actionContext, actionArguments, controller, result);
  1043. + }
  1044. + }
  1045. +
  1046. + private static void AfterActionMethodImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, IDictionary<string, object> actionArguments, object controller, IActionResult result)
  1047. + {
  1048. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterActionMethod"))
  1049. {
  1050. - diagnosticSource.Write(
  1051. + diagnosticListener.Write(
  1052. "Microsoft.AspNetCore.Mvc.AfterActionMethod",
  1053. new
  1054. {
  1055. @@ -544,17 +760,26 @@ namespace Microsoft.AspNetCore.Mvc
  1056. }
  1057. public static void BeforeOnResultExecution(
  1058. - this DiagnosticSource diagnosticSource,
  1059. + this DiagnosticListener diagnosticListener,
  1060. ResultExecutingContext resultExecutingContext,
  1061. IAsyncResultFilter filter)
  1062. {
  1063. - Debug.Assert(diagnosticSource != null);
  1064. + Debug.Assert(diagnosticListener != null);
  1065. Debug.Assert(resultExecutingContext != null);
  1066. Debug.Assert(filter != null);
  1067. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResultExecution"))
  1068. + // Inlinable fast-path check if Diagnositcs is enabled
  1069. + if (diagnosticListener.IsEnabled())
  1070. {
  1071. - diagnosticSource.Write(
  1072. + BeforeOnResultExecutionImpl(diagnosticListener, resultExecutingContext, filter);
  1073. + }
  1074. + }
  1075. +
  1076. + private static void BeforeOnResultExecutionImpl(DiagnosticListener diagnosticListener, ResultExecutingContext resultExecutingContext, IAsyncResultFilter filter)
  1077. + {
  1078. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResultExecution"))
  1079. + {
  1080. + diagnosticListener.Write(
  1081. "Microsoft.AspNetCore.Mvc.BeforeOnResultExecution",
  1082. new
  1083. {
  1084. @@ -566,17 +791,26 @@ namespace Microsoft.AspNetCore.Mvc
  1085. }
  1086. public static void AfterOnResultExecution(
  1087. - this DiagnosticSource diagnosticSource,
  1088. + this DiagnosticListener diagnosticListener,
  1089. ResultExecutedContext resultExecutedContext,
  1090. IAsyncResultFilter filter)
  1091. {
  1092. - Debug.Assert(diagnosticSource != null);
  1093. + Debug.Assert(diagnosticListener != null);
  1094. Debug.Assert(resultExecutedContext != null);
  1095. Debug.Assert(filter != null);
  1096. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResultExecution"))
  1097. + // Inlinable fast-path check if Diagnositcs is enabled
  1098. + if (diagnosticListener.IsEnabled())
  1099. + {
  1100. + AfterOnResultExecutionImpl(diagnosticListener, resultExecutedContext, filter);
  1101. + }
  1102. + }
  1103. +
  1104. + private static void AfterOnResultExecutionImpl(DiagnosticListener diagnosticListener, ResultExecutedContext resultExecutedContext, IAsyncResultFilter filter)
  1105. + {
  1106. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResultExecution"))
  1107. {
  1108. - diagnosticSource.Write(
  1109. + diagnosticListener.Write(
  1110. "Microsoft.AspNetCore.Mvc.AfterOnResultExecution",
  1111. new
  1112. {
  1113. @@ -588,17 +822,26 @@ namespace Microsoft.AspNetCore.Mvc
  1114. }
  1115. public static void BeforeOnResultExecuting(
  1116. - this DiagnosticSource diagnosticSource,
  1117. + this DiagnosticListener diagnosticListener,
  1118. ResultExecutingContext resultExecutingContext,
  1119. IResultFilter filter)
  1120. {
  1121. - Debug.Assert(diagnosticSource != null);
  1122. + Debug.Assert(diagnosticListener != null);
  1123. Debug.Assert(resultExecutingContext != null);
  1124. Debug.Assert(filter != null);
  1125. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResultExecuting"))
  1126. + // Inlinable fast-path check if Diagnositcs is enabled
  1127. + if (diagnosticListener.IsEnabled())
  1128. {
  1129. - diagnosticSource.Write(
  1130. + BeforeOnResultExecutingImpl(diagnosticListener, resultExecutingContext, filter);
  1131. + }
  1132. + }
  1133. +
  1134. + private static void BeforeOnResultExecutingImpl(DiagnosticListener diagnosticListener, ResultExecutingContext resultExecutingContext, IResultFilter filter)
  1135. + {
  1136. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResultExecuting"))
  1137. + {
  1138. + diagnosticListener.Write(
  1139. "Microsoft.AspNetCore.Mvc.BeforeOnResultExecuting",
  1140. new
  1141. {
  1142. @@ -610,17 +853,26 @@ namespace Microsoft.AspNetCore.Mvc
  1143. }
  1144. public static void AfterOnResultExecuting(
  1145. - this DiagnosticSource diagnosticSource,
  1146. + this DiagnosticListener diagnosticListener,
  1147. ResultExecutingContext resultExecutingContext,
  1148. IResultFilter filter)
  1149. {
  1150. - Debug.Assert(diagnosticSource != null);
  1151. + Debug.Assert(diagnosticListener != null);
  1152. Debug.Assert(resultExecutingContext != null);
  1153. Debug.Assert(filter != null);
  1154. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResultExecuting"))
  1155. + // Inlinable fast-path check if Diagnositcs is enabled
  1156. + if (diagnosticListener.IsEnabled())
  1157. + {
  1158. + AfterOnResultExecutingImpl(diagnosticListener, resultExecutingContext, filter);
  1159. + }
  1160. + }
  1161. +
  1162. + private static void AfterOnResultExecutingImpl(DiagnosticListener diagnosticListener, ResultExecutingContext resultExecutingContext, IResultFilter filter)
  1163. + {
  1164. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResultExecuting"))
  1165. {
  1166. - diagnosticSource.Write(
  1167. + diagnosticListener.Write(
  1168. "Microsoft.AspNetCore.Mvc.AfterOnResultExecuting",
  1169. new
  1170. {
  1171. @@ -632,17 +884,26 @@ namespace Microsoft.AspNetCore.Mvc
  1172. }
  1173. public static void BeforeOnResultExecuted(
  1174. - this DiagnosticSource diagnosticSource,
  1175. + this DiagnosticListener diagnosticListener,
  1176. ResultExecutedContext resultExecutedContext,
  1177. IResultFilter filter)
  1178. {
  1179. - Debug.Assert(diagnosticSource != null);
  1180. + Debug.Assert(diagnosticListener != null);
  1181. Debug.Assert(resultExecutedContext != null);
  1182. Debug.Assert(filter != null);
  1183. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResultExecuted"))
  1184. + // Inlinable fast-path check if Diagnositcs is enabled
  1185. + if (diagnosticListener.IsEnabled())
  1186. {
  1187. - diagnosticSource.Write(
  1188. + BeforeOnResultExecutedImpl(diagnosticListener, resultExecutedContext, filter);
  1189. + }
  1190. + }
  1191. +
  1192. + private static void BeforeOnResultExecutedImpl(DiagnosticListener diagnosticListener, ResultExecutedContext resultExecutedContext, IResultFilter filter)
  1193. + {
  1194. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnResultExecuted"))
  1195. + {
  1196. + diagnosticListener.Write(
  1197. "Microsoft.AspNetCore.Mvc.BeforeOnResultExecuted",
  1198. new
  1199. {
  1200. @@ -654,17 +915,26 @@ namespace Microsoft.AspNetCore.Mvc
  1201. }
  1202. public static void AfterOnResultExecuted(
  1203. - this DiagnosticSource diagnosticSource,
  1204. + this DiagnosticListener diagnosticListener,
  1205. ResultExecutedContext resultExecutedContext,
  1206. IResultFilter filter)
  1207. {
  1208. - Debug.Assert(diagnosticSource != null);
  1209. + Debug.Assert(diagnosticListener != null);
  1210. Debug.Assert(resultExecutedContext != null);
  1211. Debug.Assert(filter != null);
  1212. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResultExecuted"))
  1213. + // Inlinable fast-path check if Diagnositcs is enabled
  1214. + if (diagnosticListener.IsEnabled())
  1215. + {
  1216. + AfterOnResultExecutedImpl(diagnosticListener, resultExecutedContext, filter);
  1217. + }
  1218. + }
  1219. +
  1220. + private static void AfterOnResultExecutedImpl(DiagnosticListener diagnosticListener, ResultExecutedContext resultExecutedContext, IResultFilter filter)
  1221. + {
  1222. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnResultExecuted"))
  1223. {
  1224. - diagnosticSource.Write(
  1225. + diagnosticListener.Write(
  1226. "Microsoft.AspNetCore.Mvc.AfterOnResultExecuted",
  1227. new
  1228. {
  1229. @@ -676,34 +946,52 @@ namespace Microsoft.AspNetCore.Mvc
  1230. }
  1231. public static void BeforeActionResult(
  1232. - this DiagnosticSource diagnosticSource,
  1233. + this DiagnosticListener diagnosticListener,
  1234. ActionContext actionContext,
  1235. IActionResult result)
  1236. {
  1237. - Debug.Assert(diagnosticSource != null);
  1238. + Debug.Assert(diagnosticListener != null);
  1239. Debug.Assert(actionContext != null);
  1240. Debug.Assert(result != null);
  1241. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeActionResult"))
  1242. + // Inlinable fast-path check if Diagnositcs is enabled
  1243. + if (diagnosticListener.IsEnabled())
  1244. {
  1245. - diagnosticSource.Write(
  1246. + BeforeActionResultImpl(diagnosticListener, actionContext, result);
  1247. + }
  1248. + }
  1249. +
  1250. + private static void BeforeActionResultImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, IActionResult result)
  1251. + {
  1252. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeActionResult"))
  1253. + {
  1254. + diagnosticListener.Write(
  1255. "Microsoft.AspNetCore.Mvc.BeforeActionResult",
  1256. new { actionContext = actionContext, result = result });
  1257. }
  1258. }
  1259. public static void AfterActionResult(
  1260. - this DiagnosticSource diagnosticSource,
  1261. + this DiagnosticListener diagnosticListener,
  1262. ActionContext actionContext,
  1263. IActionResult result)
  1264. {
  1265. - Debug.Assert(diagnosticSource != null);
  1266. + Debug.Assert(diagnosticListener != null);
  1267. Debug.Assert(actionContext != null);
  1268. Debug.Assert(result != null);
  1269. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterActionResult"))
  1270. + // Inlinable fast-path check if Diagnositcs is enabled
  1271. + if (diagnosticListener.IsEnabled())
  1272. + {
  1273. + AfterActionResultImpl(diagnosticListener, actionContext, result);
  1274. + }
  1275. + }
  1276. +
  1277. + private static void AfterActionResultImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, IActionResult result)
  1278. + {
  1279. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterActionResult"))
  1280. {
  1281. - diagnosticSource.Write(
  1282. + diagnosticListener.Write(
  1283. "Microsoft.AspNetCore.Mvc.AfterActionResult",
  1284. new { actionContext = actionContext, result = result });
  1285. }
  1286. diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Routing/MvcAttributeRouteHandler.cs b/src/Microsoft.AspNetCore.Mvc.Core/Routing/MvcAttributeRouteHandler.cs
  1287. index ffc91d11d11..f32032f7604 100644
  1288. --- a/src/Microsoft.AspNetCore.Mvc.Core/Routing/MvcAttributeRouteHandler.cs
  1289. +++ b/src/Microsoft.AspNetCore.Mvc.Core/Routing/MvcAttributeRouteHandler.cs
  1290. @@ -18,21 +18,21 @@ namespace Microsoft.AspNetCore.Mvc.Routing
  1291. private readonly IActionInvokerFactory _actionInvokerFactory;
  1292. private readonly IActionSelector _actionSelector;
  1293. private readonly ILogger _logger;
  1294. - private DiagnosticSource _diagnosticSource;
  1295. + private DiagnosticListener _diagnosticListener;
  1296. public MvcAttributeRouteHandler(
  1297. IActionInvokerFactory actionInvokerFactory,
  1298. IActionSelector actionSelector,
  1299. - DiagnosticSource diagnosticSource,
  1300. + DiagnosticListener diagnosticListener,
  1301. ILoggerFactory loggerFactory)
  1302. - : this(actionInvokerFactory, actionSelector, diagnosticSource, loggerFactory, actionContextAccessor: null)
  1303. + : this(actionInvokerFactory, actionSelector, diagnosticListener, loggerFactory, actionContextAccessor: null)
  1304. {
  1305. }
  1306. public MvcAttributeRouteHandler(
  1307. IActionInvokerFactory actionInvokerFactory,
  1308. IActionSelector actionSelector,
  1309. - DiagnosticSource diagnosticSource,
  1310. + DiagnosticListener diagnosticListener,
  1311. ILoggerFactory loggerFactory,
  1312. IActionContextAccessor actionContextAccessor)
  1313. {
  1314. @@ -42,7 +42,7 @@ namespace Microsoft.AspNetCore.Mvc.Routing
  1315. _actionInvokerFactory = actionInvokerFactory;
  1316. _actionSelector = actionSelector;
  1317. - _diagnosticSource = diagnosticSource;
  1318. + _diagnosticListener = diagnosticListener;
  1319. _logger = loggerFactory.CreateLogger<MvcAttributeRouteHandler>();
  1320. }
  1321. diff --git a/src/Microsoft.AspNetCore.Mvc.Core/Routing/MvcRouteHandler.cs b/src/Microsoft.AspNetCore.Mvc.Core/Routing/MvcRouteHandler.cs
  1322. index a4c31e78c8f..3d7e1add1ee 100644
  1323. --- a/src/Microsoft.AspNetCore.Mvc.Core/Routing/MvcRouteHandler.cs
  1324. +++ b/src/Microsoft.AspNetCore.Mvc.Core/Routing/MvcRouteHandler.cs
  1325. @@ -17,21 +17,21 @@ namespace Microsoft.AspNetCore.Mvc.Routing
  1326. private readonly IActionInvokerFactory _actionInvokerFactory;
  1327. private readonly IActionSelector _actionSelector;
  1328. private readonly ILogger _logger;
  1329. - private readonly DiagnosticSource _diagnosticSource;
  1330. + private readonly DiagnosticListener _diagnosticListener;
  1331. public MvcRouteHandler(
  1332. IActionInvokerFactory actionInvokerFactory,
  1333. IActionSelector actionSelector,
  1334. - DiagnosticSource diagnosticSource,
  1335. + DiagnosticListener diagnosticListener,
  1336. ILoggerFactory loggerFactory)
  1337. - : this(actionInvokerFactory, actionSelector, diagnosticSource, loggerFactory, actionContextAccessor: null)
  1338. + : this(actionInvokerFactory, actionSelector, diagnosticListener, loggerFactory, actionContextAccessor: null)
  1339. {
  1340. }
  1341. public MvcRouteHandler(
  1342. IActionInvokerFactory actionInvokerFactory,
  1343. IActionSelector actionSelector,
  1344. - DiagnosticSource diagnosticSource,
  1345. + DiagnosticListener diagnosticListener,
  1346. ILoggerFactory loggerFactory,
  1347. IActionContextAccessor actionContextAccessor)
  1348. {
  1349. @@ -41,7 +41,7 @@ namespace Microsoft.AspNetCore.Mvc.Routing
  1350. _actionInvokerFactory = actionInvokerFactory;
  1351. _actionSelector = actionSelector;
  1352. - _diagnosticSource = diagnosticSource;
  1353. + _diagnosticListener = diagnosticListener;
  1354. _logger = loggerFactory.CreateLogger<MvcRouteHandler>();
  1355. }
  1356. diff --git a/src/Microsoft.AspNetCore.Mvc.Razor/DependencyInjection/MvcRazorMvcCoreBuilderExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Razor/DependencyInjection/MvcRazorMvcCoreBuilderExtensions.cs
  1357. index 64c4b4d3a97..c3f6388252e 100644
  1358. --- a/src/Microsoft.AspNetCore.Mvc.Razor/DependencyInjection/MvcRazorMvcCoreBuilderExtensions.cs
  1359. +++ b/src/Microsoft.AspNetCore.Mvc.Razor/DependencyInjection/MvcRazorMvcCoreBuilderExtensions.cs
  1360. @@ -174,9 +174,9 @@ namespace Microsoft.Extensions.DependencyInjection
  1361. var optionsAccessor = s.GetRequiredService<IOptions<RazorViewEngineOptions>>();
  1362. var razorFileSystem = s.GetRequiredService<RazorProjectFileSystem>();
  1363. var loggerFactory = s.GetRequiredService<ILoggerFactory>();
  1364. - var diagnosticSource = s.GetRequiredService<DiagnosticSource>();
  1365. + var diagnosticListener = s.GetRequiredService<DiagnosticListener>();
  1366. - var viewEngine = new RazorViewEngine(pageFactory, pageActivator, htmlEncoder, optionsAccessor, razorFileSystem, loggerFactory, diagnosticSource);
  1367. + var viewEngine = new RazorViewEngine(pageFactory, pageActivator, htmlEncoder, optionsAccessor, razorFileSystem, loggerFactory, diagnosticListener);
  1368. return viewEngine;
  1369. });
  1370. services.TryAddSingleton<IViewCompilerProvider, RazorViewCompilerProvider>();
  1371. diff --git a/src/Microsoft.AspNetCore.Mvc.Razor/MvcRazorDiagnosticSourceExtensions.cs b/src/Microsoft.AspNetCore.Mvc.Razor/MvcRazorDiagnosticSourceExtensions.cs
  1372. index d6706ed56df..f0479ef1430 100644
  1373. --- a/src/Microsoft.AspNetCore.Mvc.Razor/MvcRazorDiagnosticSourceExtensions.cs
  1374. +++ b/src/Microsoft.AspNetCore.Mvc.Razor/MvcRazorDiagnosticSourceExtensions.cs
  1375. @@ -9,13 +9,25 @@ namespace Microsoft.AspNetCore.Mvc.Razor
  1376. internal static class MvcRazorDiagnosticSourceExtensions
  1377. {
  1378. public static void BeforeViewPage(
  1379. - this DiagnosticSource diagnosticSource,
  1380. + this DiagnosticListener diagnosticListener,
  1381. IRazorPage page,
  1382. ViewContext viewContext)
  1383. {
  1384. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.Razor.BeforeViewPage"))
  1385. + // Inlinable fast-path check if Diagnositcs is enabled
  1386. + if (diagnosticListener.IsEnabled())
  1387. {
  1388. - diagnosticSource.Write(
  1389. + BeforeViewPageImpl(diagnosticListener, page, viewContext);
  1390. + }
  1391. + }
  1392. +
  1393. + private static void BeforeViewPageImpl(
  1394. + this DiagnosticListener diagnosticListener,
  1395. + IRazorPage page,
  1396. + ViewContext viewContext)
  1397. + {
  1398. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.Razor.BeforeViewPage"))
  1399. + {
  1400. + diagnosticListener.Write(
  1401. "Microsoft.AspNetCore.Mvc.Razor.BeforeViewPage",
  1402. new
  1403. {
  1404. @@ -28,13 +40,25 @@ namespace Microsoft.AspNetCore.Mvc.Razor
  1405. }
  1406. public static void AfterViewPage(
  1407. - this DiagnosticSource diagnosticSource,
  1408. + this DiagnosticListener diagnosticListener,
  1409. + IRazorPage page,
  1410. + ViewContext viewContext)
  1411. + {
  1412. + // Inlinable fast-path check if Diagnositcs is enabled
  1413. + if (diagnosticListener.IsEnabled())
  1414. + {
  1415. + AfterViewPageImpl(diagnosticListener, page, viewContext);
  1416. + }
  1417. + }
  1418. +
  1419. + private static void AfterViewPageImpl(
  1420. + this DiagnosticListener diagnosticListener,
  1421. IRazorPage page,
  1422. ViewContext viewContext)
  1423. {
  1424. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.Razor.AfterViewPage"))
  1425. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.Razor.AfterViewPage"))
  1426. {
  1427. - diagnosticSource.Write(
  1428. + diagnosticListener.Write(
  1429. "Microsoft.AspNetCore.Mvc.Razor.AfterViewPage",
  1430. new
  1431. {
  1432. diff --git a/src/Microsoft.AspNetCore.Mvc.Razor/RazorView.cs b/src/Microsoft.AspNetCore.Mvc.Razor/RazorView.cs
  1433. index e6e75ce12d8..8b5b3ebe901 100644
  1434. --- a/src/Microsoft.AspNetCore.Mvc.Razor/RazorView.cs
  1435. +++ b/src/Microsoft.AspNetCore.Mvc.Razor/RazorView.cs
  1436. @@ -23,7 +23,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
  1437. private readonly IRazorViewEngine _viewEngine;
  1438. private readonly IRazorPageActivator _pageActivator;
  1439. private readonly HtmlEncoder _htmlEncoder;
  1440. - private readonly DiagnosticSource _diagnosticSource;
  1441. + private readonly DiagnosticListener _diagnosticListener;
  1442. private IViewBufferScope _bufferScope;
  1443. /// <summary>
  1444. @@ -35,14 +35,14 @@ namespace Microsoft.AspNetCore.Mvc.Razor
  1445. /// </param>
  1446. /// <param name="razorPage">The <see cref="IRazorPage"/> instance to execute.</param>
  1447. /// <param name="htmlEncoder">The HTML encoder.</param>
  1448. - /// <param name="diagnosticSource">The <see cref="DiagnosticSource"/>.</param>
  1449. + /// <param name="diagnosticListener">The <see cref="DiagnosticListener"/>.</param>
  1450. public RazorView(
  1451. IRazorViewEngine viewEngine,
  1452. IRazorPageActivator pageActivator,
  1453. IReadOnlyList<IRazorPage> viewStartPages,
  1454. IRazorPage razorPage,
  1455. HtmlEncoder htmlEncoder,
  1456. - DiagnosticSource diagnosticSource)
  1457. + DiagnosticListener diagnosticListener)
  1458. {
  1459. if (viewEngine == null)
  1460. {
  1461. @@ -69,9 +69,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor
  1462. throw new ArgumentNullException(nameof(htmlEncoder));
  1463. }
  1464. - if (diagnosticSource == null)
  1465. + if (diagnosticListener == null)
  1466. {
  1467. - throw new ArgumentNullException(nameof(diagnosticSource));
  1468. + throw new ArgumentNullException(nameof(diagnosticListener));
  1469. }
  1470. _viewEngine = viewEngine;
  1471. @@ -79,7 +79,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
  1472. ViewStartPages = viewStartPages;
  1473. RazorPage = razorPage;
  1474. _htmlEncoder = htmlEncoder;
  1475. - _diagnosticSource = diagnosticSource;
  1476. + _diagnosticListener = diagnosticListener;
  1477. }
  1478. /// <inheritdoc />
  1479. @@ -170,7 +170,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
  1480. OnAfterPageActivated?.Invoke(page, context);
  1481. - _diagnosticSource.BeforeViewPage(page, context);
  1482. + _diagnosticListener.BeforeViewPage(page, context);
  1483. try
  1484. {
  1485. @@ -178,7 +178,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
  1486. }
  1487. finally
  1488. {
  1489. - _diagnosticSource.AfterViewPage(page, context);
  1490. + _diagnosticListener.AfterViewPage(page, context);
  1491. }
  1492. }
  1493. diff --git a/src/Microsoft.AspNetCore.Mvc.Razor/RazorViewEngine.cs b/src/Microsoft.AspNetCore.Mvc.Razor/RazorViewEngine.cs
  1494. index 9bbe9cfb135..026d8c88aea 100644
  1495. --- a/src/Microsoft.AspNetCore.Mvc.Razor/RazorViewEngine.cs
  1496. +++ b/src/Microsoft.AspNetCore.Mvc.Razor/RazorViewEngine.cs
  1497. @@ -43,7 +43,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
  1498. private readonly ILogger _logger;
  1499. private readonly RazorViewEngineOptions _options;
  1500. private readonly RazorProject _razorFileSystem;
  1501. - private readonly DiagnosticSource _diagnosticSource;
  1502. + private readonly DiagnosticListener _diagnosticListener;
  1503. /// <summary>
  1504. /// Initializes a new instance of the <see cref="RazorViewEngine" />.
  1505. @@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
  1506. IOptions<RazorViewEngineOptions> optionsAccessor,
  1507. RazorProject razorProject,
  1508. ILoggerFactory loggerFactory,
  1509. - DiagnosticSource diagnosticSource)
  1510. + DiagnosticListener diagnosticListener)
  1511. {
  1512. _options = optionsAccessor.Value;
  1513. @@ -79,7 +79,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
  1514. _htmlEncoder = htmlEncoder;
  1515. _logger = loggerFactory.CreateLogger<RazorViewEngine>();
  1516. _razorFileSystem = razorProject;
  1517. - _diagnosticSource = diagnosticSource;
  1518. + _diagnosticListener = diagnosticListener;
  1519. ViewLookupCache = new MemoryCache(new MemoryCacheOptions());
  1520. }
  1521. @@ -93,9 +93,9 @@ namespace Microsoft.AspNetCore.Mvc.Razor
  1522. IOptions<RazorViewEngineOptions> optionsAccessor,
  1523. RazorProjectFileSystem razorFileSystem,
  1524. ILoggerFactory loggerFactory,
  1525. - DiagnosticSource diagnosticSource)
  1526. + DiagnosticListener diagnosticListener)
  1527. #pragma warning disable CS0618 // Type or member is obsolete
  1528. - : this (pageFactory, pageActivator, htmlEncoder, optionsAccessor, (RazorProject)razorFileSystem, loggerFactory, diagnosticSource)
  1529. + : this (pageFactory, pageActivator, htmlEncoder, optionsAccessor, (RazorProject)razorFileSystem, loggerFactory, diagnosticListener)
  1530. #pragma warning restore CS0618 // Type or member is obsolete
  1531. {
  1532. }
  1533. @@ -498,7 +498,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
  1534. viewStarts[i] = viewStartItem.PageFactory();
  1535. }
  1536. - var view = new RazorView(this, _pageActivator, viewStarts, page, _htmlEncoder, _diagnosticSource);
  1537. + var view = new RazorView(this, _pageActivator, viewStarts, page, _htmlEncoder, _diagnosticListener);
  1538. return ViewEngineResult.Found(viewName, view);
  1539. }
  1540. diff --git a/src/Microsoft.AspNetCore.Mvc.Razor/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Mvc.Razor/breakingchanges.netcore.json
  1541. new file mode 100644
  1542. index 00000000000..ee5093114a7
  1543. --- /dev/null
  1544. +++ b/src/Microsoft.AspNetCore.Mvc.Razor/breakingchanges.netcore.json
  1545. @@ -0,0 +1,17 @@
  1546. +[
  1547. + {
  1548. + "TypeId": "public class Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine : Microsoft.AspNetCore.Mvc.Razor.IRazorViewEngine",
  1549. + "MemberId": "public .ctor(Microsoft.AspNetCore.Mvc.Razor.IRazorPageFactoryProvider pageFactory, Microsoft.AspNetCore.Mvc.Razor.IRazorPageActivator pageActivator, System.Text.Encodings.Web.HtmlEncoder htmlEncoder, Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Mvc.Razor.RazorViewEngineOptions> optionsAccessor, Microsoft.AspNetCore.Razor.Language.RazorProject razorProject, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, System.Diagnostics.DiagnosticSource diagnosticSource)",
  1550. + "Kind": "Removal"
  1551. + },
  1552. + {
  1553. + "TypeId": "public class Microsoft.AspNetCore.Mvc.Razor.RazorViewEngine : Microsoft.AspNetCore.Mvc.Razor.IRazorViewEngine",
  1554. + "MemberId": "public .ctor(Microsoft.AspNetCore.Mvc.Razor.IRazorPageFactoryProvider pageFactory, Microsoft.AspNetCore.Mvc.Razor.IRazorPageActivator pageActivator, System.Text.Encodings.Web.HtmlEncoder htmlEncoder, Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Mvc.Razor.RazorViewEngineOptions> optionsAccessor, Microsoft.AspNetCore.Razor.Language.RazorProjectFileSystem razorFileSystem, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, System.Diagnostics.DiagnosticSource diagnosticSource)",
  1555. + "Kind": "Removal"
  1556. + },
  1557. + {
  1558. + "TypeId": "public class Microsoft.AspNetCore.Mvc.Razor.RazorView : Microsoft.AspNetCore.Mvc.ViewEngines.IView",
  1559. + "MemberId": "public .ctor(Microsoft.AspNetCore.Mvc.Razor.IRazorViewEngine viewEngine, Microsoft.AspNetCore.Mvc.Razor.IRazorPageActivator pageActivator, System.Collections.Generic.IReadOnlyList<Microsoft.AspNetCore.Mvc.Razor.IRazorPage> viewStartPages, Microsoft.AspNetCore.Mvc.Razor.IRazorPage razorPage, System.Text.Encodings.Web.HtmlEncoder htmlEncoder, System.Diagnostics.DiagnosticSource diagnosticSource)",
  1560. + "Kind": "Removal"
  1561. + }
  1562. +]
  1563. diff --git a/src/Microsoft.AspNetCore.Mvc.RazorPages/Infrastructure/DefaultPageFactoryProvider.cs b/src/Microsoft.AspNetCore.Mvc.RazorPages/Infrastructure/DefaultPageFactoryProvider.cs
  1564. index 899175d215f..a5adaa11c37 100644
  1565. --- a/src/Microsoft.AspNetCore.Mvc.RazorPages/Infrastructure/DefaultPageFactoryProvider.cs
  1566. +++ b/src/Microsoft.AspNetCore.Mvc.RazorPages/Infrastructure/DefaultPageFactoryProvider.cs
  1567. @@ -24,7 +24,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
  1568. IModelMetadataProvider metadataProvider,
  1569. IUrlHelperFactory urlHelperFactory,
  1570. IJsonHelper jsonHelper,
  1571. - DiagnosticSource diagnosticSource,
  1572. + DiagnosticListener diagnosticListener,
  1573. HtmlEncoder htmlEncoder,
  1574. IModelExpressionProvider modelExpressionProvider)
  1575. {
  1576. @@ -34,7 +34,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
  1577. {
  1578. UrlHelperAccessor = context => urlHelperFactory.GetUrlHelper(context),
  1579. JsonHelperAccessor = context => jsonHelper,
  1580. - DiagnosticSourceAccessor = context => diagnosticSource,
  1581. + DiagnosticSourceAccessor = context => diagnosticListener,
  1582. HtmlEncoderAccessor = context => htmlEncoder,
  1583. ModelExpressionProviderAccessor = context => modelExpressionProvider,
  1584. };
  1585. diff --git a/src/Microsoft.AspNetCore.Mvc.RazorPages/Infrastructure/PageActionInvoker.cs b/src/Microsoft.AspNetCore.Mvc.RazorPages/Infrastructure/PageActionInvoker.cs
  1586. index 1fa0739e1bc..8bcdad905b7 100644
  1587. --- a/src/Microsoft.AspNetCore.Mvc.RazorPages/Infrastructure/PageActionInvoker.cs
  1588. +++ b/src/Microsoft.AspNetCore.Mvc.RazorPages/Infrastructure/PageActionInvoker.cs
  1589. @@ -39,7 +39,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
  1590. public PageActionInvoker(
  1591. IPageHandlerMethodSelector handlerMethodSelector,
  1592. - DiagnosticSource diagnosticSource,
  1593. + DiagnosticListener diagnosticListener,
  1594. ILogger logger,
  1595. IActionResultTypeMapper mapper,
  1596. PageContext pageContext,
  1597. @@ -49,7 +49,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
  1598. ITempDataDictionaryFactory tempDataFactory,
  1599. HtmlHelperOptions htmlHelperOptions)
  1600. : base(
  1601. - diagnosticSource,
  1602. + diagnosticListener,
  1603. logger,
  1604. mapper,
  1605. pageContext,
  1606. @@ -255,7 +255,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
  1607. Debug.Assert(executor != null, "We should always find a executor for a handler");
  1608. - _diagnosticSource.BeforeHandlerMethod(_pageContext, handler, _arguments, _instance);
  1609. + _diagnosticListener.BeforeHandlerMethod(_pageContext, handler, _arguments, _instance);
  1610. _logger.ExecutingHandlerMethod(_pageContext, handler, arguments);
  1611. try
  1612. @@ -265,7 +265,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
  1613. }
  1614. finally
  1615. {
  1616. - _diagnosticSource.AfterHandlerMethod(_pageContext, handler, _arguments, _instance, _result);
  1617. + _diagnosticListener.AfterHandlerMethod(_pageContext, handler, _arguments, _instance, _result);
  1618. }
  1619. }
  1620. @@ -347,7 +347,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
  1621. var filter = (IAsyncPageFilter)state;
  1622. var handlerSelectedContext = _handlerSelectedContext;
  1623. - _diagnosticSource.BeforeOnPageHandlerSelection(handlerSelectedContext, filter);
  1624. + _diagnosticListener.BeforeOnPageHandlerSelection(handlerSelectedContext, filter);
  1625. _logger.BeforeExecutingMethodOnFilter(
  1626. PageLoggerExtensions.PageFilter,
  1627. nameof(IAsyncPageFilter.OnPageHandlerSelectionAsync),
  1628. @@ -370,7 +370,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
  1629. var filter = (IAsyncPageFilter)state;
  1630. - _diagnosticSource.AfterOnPageHandlerSelection(_handlerSelectedContext, filter);
  1631. + _diagnosticListener.AfterOnPageHandlerSelection(_handlerSelectedContext, filter);
  1632. _logger.AfterExecutingMethodOnFilter(
  1633. PageLoggerExtensions.PageFilter,
  1634. nameof(IAsyncPageFilter.OnPageHandlerSelectionAsync),
  1635. @@ -387,7 +387,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
  1636. var filter = (IPageFilter)state;
  1637. var handlerSelectedContext = _handlerSelectedContext;
  1638. - _diagnosticSource.BeforeOnPageHandlerSelected(handlerSelectedContext, filter);
  1639. + _diagnosticListener.BeforeOnPageHandlerSelected(handlerSelectedContext, filter);
  1640. _logger.BeforeExecutingMethodOnFilter(
  1641. PageLoggerExtensions.PageFilter,
  1642. nameof(IPageFilter.OnPageHandlerSelected),
  1643. @@ -395,7 +395,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
  1644. filter.OnPageHandlerSelected(handlerSelectedContext);
  1645. - _diagnosticSource.AfterOnPageHandlerSelected(handlerSelectedContext, filter);
  1646. + _diagnosticListener.AfterOnPageHandlerSelected(handlerSelectedContext, filter);
  1647. goto case State.PageSelectHandlerNext;
  1648. }
  1649. @@ -458,7 +458,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
  1650. var filter = (IAsyncPageFilter)state;
  1651. var handlerExecutingContext = _handlerExecutingContext;
  1652. - _diagnosticSource.BeforeOnPageHandlerExecution(handlerExecutingContext, filter);
  1653. + _diagnosticListener.BeforeOnPageHandlerExecution(handlerExecutingContext, filter);
  1654. _logger.BeforeExecutingMethodOnFilter(
  1655. PageLoggerExtensions.PageFilter,
  1656. nameof(IAsyncPageFilter.OnPageHandlerExecutionAsync),
  1657. @@ -497,7 +497,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
  1658. };
  1659. }
  1660. - _diagnosticSource.AfterOnPageHandlerExecution(_handlerExecutedContext, filter);
  1661. + _diagnosticListener.AfterOnPageHandlerExecution(_handlerExecutedContext, filter);
  1662. _logger.AfterExecutingMethodOnFilter(
  1663. PageLoggerExtensions.PageFilter,
  1664. nameof(IAsyncPageFilter.OnPageHandlerExecutionAsync),
  1665. @@ -514,7 +514,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
  1666. var filter = (IPageFilter)state;
  1667. var handlerExecutingContext = _handlerExecutingContext;
  1668. - _diagnosticSource.BeforeOnPageHandlerExecuting(handlerExecutingContext, filter);
  1669. + _diagnosticListener.BeforeOnPageHandlerExecuting(handlerExecutingContext, filter);
  1670. _logger.BeforeExecutingMethodOnFilter(
  1671. PageLoggerExtensions.PageFilter,
  1672. nameof(IPageFilter.OnPageHandlerExecuting),
  1673. @@ -522,7 +522,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
  1674. filter.OnPageHandlerExecuting(handlerExecutingContext);
  1675. - _diagnosticSource.AfterOnPageHandlerExecuting(handlerExecutingContext, filter);
  1676. + _diagnosticListener.AfterOnPageHandlerExecuting(handlerExecutingContext, filter);
  1677. _logger.AfterExecutingMethodOnFilter(
  1678. PageLoggerExtensions.PageFilter,
  1679. nameof(IPageFilter.OnPageHandlerExecuting),
  1680. @@ -565,7 +565,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
  1681. var filter = (IPageFilter)state;
  1682. var handlerExecutedContext = _handlerExecutedContext;
  1683. - _diagnosticSource.BeforeOnPageHandlerExecuted(handlerExecutedContext, filter);
  1684. + _diagnosticListener.BeforeOnPageHandlerExecuted(handlerExecutedContext, filter);
  1685. _logger.BeforeExecutingMethodOnFilter(
  1686. PageLoggerExtensions.PageFilter,
  1687. nameof(IPageFilter.OnPageHandlerExecuted),
  1688. @@ -573,7 +573,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
  1689. filter.OnPageHandlerExecuted(handlerExecutedContext);
  1690. - _diagnosticSource.AfterOnPageHandlerExecuted(handlerExecutedContext, filter);
  1691. + _diagnosticListener.AfterOnPageHandlerExecuted(handlerExecutedContext, filter);
  1692. _logger.AfterExecutingMethodOnFilter(
  1693. PageLoggerExtensions.PageFilter,
  1694. nameof(IPageFilter.OnPageHandlerExecuted),
  1695. diff --git a/src/Microsoft.AspNetCore.Mvc.RazorPages/Infrastructure/PageActionInvokerProvider.cs b/src/Microsoft.AspNetCore.Mvc.RazorPages/Infrastructure/PageActionInvokerProvider.cs
  1696. index f1a54850d34..e5fd4e97c9c 100644
  1697. --- a/src/Microsoft.AspNetCore.Mvc.RazorPages/Infrastructure/PageActionInvokerProvider.cs
  1698. +++ b/src/Microsoft.AspNetCore.Mvc.RazorPages/Infrastructure/PageActionInvokerProvider.cs
  1699. @@ -37,7 +37,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
  1700. private readonly HtmlHelperOptions _htmlHelperOptions;
  1701. private readonly IPageHandlerMethodSelector _selector;
  1702. private readonly RazorProjectFileSystem _razorFileSystem;
  1703. - private readonly DiagnosticSource _diagnosticSource;
  1704. + private readonly DiagnosticListener _diagnosticListener;
  1705. private readonly ILogger<PageActionInvoker> _logger;
  1706. private readonly IActionResultTypeMapper _mapper;
  1707. private volatile InnerCache _currentCache;
  1708. @@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
  1709. IOptions<HtmlHelperOptions> htmlHelperOptions,
  1710. IPageHandlerMethodSelector selector,
  1711. RazorProjectFileSystem razorFileSystem,
  1712. - DiagnosticSource diagnosticSource,
  1713. + DiagnosticListener diagnosticListener,
  1714. ILoggerFactory loggerFactory,
  1715. IActionResultTypeMapper mapper)
  1716. {
  1717. @@ -76,7 +76,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
  1718. _htmlHelperOptions = htmlHelperOptions.Value;
  1719. _selector = selector;
  1720. _razorFileSystem = razorFileSystem;
  1721. - _diagnosticSource = diagnosticSource;
  1722. + _diagnosticListener = diagnosticListener;
  1723. _logger = loggerFactory.CreateLogger<PageActionInvoker>();
  1724. _mapper = mapper;
  1725. }
  1726. @@ -156,7 +156,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
  1727. return new PageActionInvoker(
  1728. _selector,
  1729. - _diagnosticSource,
  1730. + _diagnosticListener,
  1731. _logger,
  1732. _mapper,
  1733. pageContext,
  1734. diff --git a/src/Microsoft.AspNetCore.Mvc.RazorPages/Infrastructure/PageResultExecutor.cs b/src/Microsoft.AspNetCore.Mvc.RazorPages/Infrastructure/PageResultExecutor.cs
  1735. index 17a5c8e68ba..9ce8e7d6a97 100644
  1736. --- a/src/Microsoft.AspNetCore.Mvc.RazorPages/Infrastructure/PageResultExecutor.cs
  1737. +++ b/src/Microsoft.AspNetCore.Mvc.RazorPages/Infrastructure/PageResultExecutor.cs
  1738. @@ -20,7 +20,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
  1739. {
  1740. private readonly IRazorViewEngine _razorViewEngine;
  1741. private readonly IRazorPageActivator _razorPageActivator;
  1742. - private readonly DiagnosticSource _diagnosticSource;
  1743. + private readonly DiagnosticListener _diagnosticListener;
  1744. private readonly HtmlEncoder _htmlEncoder;
  1745. /// <summary>
  1746. @@ -30,21 +30,21 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
  1747. /// <param name="compositeViewEngine">The <see cref="ICompositeViewEngine"/>.</param>
  1748. /// <param name="razorViewEngine">The <see cref="IRazorViewEngine"/>.</param>
  1749. /// <param name="razorPageActivator">The <see cref="IRazorPageActivator"/>.</param>
  1750. - /// <param name="diagnosticSource">The <see cref="DiagnosticSource"/>.</param>
  1751. + /// <param name="diagnosticListener">The <see cref="DiagnosticListener"/>.</param>
  1752. /// <param name="htmlEncoder">The <see cref="HtmlEncoder"/>.</param>
  1753. public PageResultExecutor(
  1754. IHttpResponseStreamWriterFactory writerFactory,
  1755. ICompositeViewEngine compositeViewEngine,
  1756. IRazorViewEngine razorViewEngine,
  1757. IRazorPageActivator razorPageActivator,
  1758. - DiagnosticSource diagnosticSource,
  1759. + DiagnosticListener diagnosticListener,
  1760. HtmlEncoder htmlEncoder)
  1761. - : base(writerFactory, compositeViewEngine, diagnosticSource)
  1762. + : base(writerFactory, compositeViewEngine, diagnosticListener)
  1763. {
  1764. _razorViewEngine = razorViewEngine;
  1765. _htmlEncoder = htmlEncoder;
  1766. _razorPageActivator = razorPageActivator;
  1767. - _diagnosticSource = diagnosticSource;
  1768. + _diagnosticListener = diagnosticListener;
  1769. }
  1770. /// <summary>
  1771. @@ -84,7 +84,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
  1772. viewStarts,
  1773. pageAdapter,
  1774. _htmlEncoder,
  1775. - _diagnosticSource)
  1776. + _diagnosticListener)
  1777. {
  1778. OnAfterPageActivated = (page, currentViewContext) =>
  1779. {
  1780. diff --git a/src/Microsoft.AspNetCore.Mvc.RazorPages/MvcRazorPagesDiagnosticSourceExtensions.cs b/src/Microsoft.AspNetCore.Mvc.RazorPages/MvcRazorPagesDiagnosticSourceExtensions.cs
  1781. index 54dd75df95a..5747c9828fb 100644
  1782. --- a/src/Microsoft.AspNetCore.Mvc.RazorPages/MvcRazorPagesDiagnosticSourceExtensions.cs
  1783. +++ b/src/Microsoft.AspNetCore.Mvc.RazorPages/MvcRazorPagesDiagnosticSourceExtensions.cs
  1784. @@ -11,21 +11,30 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
  1785. internal static class MvcRazorPagesDiagnosticSourceExtensions
  1786. {
  1787. public static void BeforeHandlerMethod(
  1788. - this DiagnosticSource diagnosticSource,
  1789. + this DiagnosticListener diagnosticListener,
  1790. ActionContext actionContext,
  1791. HandlerMethodDescriptor handlerMethodDescriptor,
  1792. IDictionary<string, object> arguments,
  1793. object instance)
  1794. {
  1795. - Debug.Assert(diagnosticSource != null);
  1796. + Debug.Assert(diagnosticListener != null);
  1797. Debug.Assert(actionContext != null);
  1798. Debug.Assert(handlerMethodDescriptor != null);
  1799. Debug.Assert(arguments != null);
  1800. Debug.Assert(instance != null);
  1801. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeHandlerMethod"))
  1802. + // Inlinable fast-path check if Diagnositcs is enabled
  1803. + if (diagnosticListener.IsEnabled())
  1804. {
  1805. - diagnosticSource.Write(
  1806. + BeforeHandlerMethodImpl(diagnosticListener, actionContext, handlerMethodDescriptor, arguments, instance);
  1807. + }
  1808. + }
  1809. +
  1810. + private static void BeforeHandlerMethodImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, HandlerMethodDescriptor handlerMethodDescriptor, IDictionary<string, object> arguments, object instance)
  1811. + {
  1812. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeHandlerMethod"))
  1813. + {
  1814. + diagnosticListener.Write(
  1815. "Microsoft.AspNetCore.Mvc.BeforeHandlerMethod",
  1816. new
  1817. {
  1818. @@ -38,22 +47,31 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
  1819. }
  1820. public static void AfterHandlerMethod(
  1821. - this DiagnosticSource diagnosticSource,
  1822. + this DiagnosticListener diagnosticListener,
  1823. ActionContext actionContext,
  1824. HandlerMethodDescriptor handlerMethodDescriptor,
  1825. IDictionary<string, object> arguments,
  1826. object instance,
  1827. IActionResult result)
  1828. {
  1829. - Debug.Assert(diagnosticSource != null);
  1830. + Debug.Assert(diagnosticListener != null);
  1831. Debug.Assert(actionContext != null);
  1832. Debug.Assert(handlerMethodDescriptor != null);
  1833. Debug.Assert(arguments != null);
  1834. Debug.Assert(instance != null);
  1835. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterHandlerMethod"))
  1836. + // Inlinable fast-path check if Diagnositcs is enabled
  1837. + if (diagnosticListener.IsEnabled())
  1838. + {
  1839. + AfterHandlerMethodImpl(diagnosticListener, actionContext, handlerMethodDescriptor, arguments, instance, result);
  1840. + }
  1841. + }
  1842. +
  1843. + private static void AfterHandlerMethodImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, HandlerMethodDescriptor handlerMethodDescriptor, IDictionary<string, object> arguments, object instance, IActionResult result)
  1844. + {
  1845. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterHandlerMethod"))
  1846. {
  1847. - diagnosticSource.Write(
  1848. + diagnosticListener.Write(
  1849. "Microsoft.AspNetCore.Mvc.AfterHandlerMethod",
  1850. new
  1851. {
  1852. @@ -65,19 +83,28 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
  1853. });
  1854. }
  1855. }
  1856. -
  1857. +
  1858. public static void BeforeOnPageHandlerExecution(
  1859. - this DiagnosticSource diagnosticSource,
  1860. + this DiagnosticListener diagnosticListener,
  1861. PageHandlerExecutingContext handlerExecutionContext,
  1862. IAsyncPageFilter filter)
  1863. {
  1864. - Debug.Assert(diagnosticSource != null);
  1865. + Debug.Assert(diagnosticListener != null);
  1866. Debug.Assert(handlerExecutionContext != null);
  1867. Debug.Assert(filter != null);
  1868. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecution"))
  1869. + // Inlinable fast-path check if Diagnositcs is enabled
  1870. + if (diagnosticListener.IsEnabled())
  1871. + {
  1872. + BeforeOnPageHandlerExecutionImpl(diagnosticListener, handlerExecutionContext, filter);
  1873. + }
  1874. + }
  1875. +
  1876. + private static void BeforeOnPageHandlerExecutionImpl(DiagnosticListener diagnosticListener, PageHandlerExecutingContext handlerExecutionContext, IAsyncPageFilter filter)
  1877. + {
  1878. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecution"))
  1879. {
  1880. - diagnosticSource.Write(
  1881. + diagnosticListener.Write(
  1882. "Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecution",
  1883. new
  1884. {
  1885. @@ -89,17 +116,26 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
  1886. }
  1887. public static void AfterOnPageHandlerExecution(
  1888. - this DiagnosticSource diagnosticSource,
  1889. + this DiagnosticListener diagnosticListener,
  1890. PageHandlerExecutedContext handlerExecutedContext,
  1891. IAsyncPageFilter filter)
  1892. {
  1893. - Debug.Assert(diagnosticSource != null);
  1894. + Debug.Assert(diagnosticListener != null);
  1895. Debug.Assert(handlerExecutedContext != null);
  1896. Debug.Assert(filter != null);
  1897. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecution"))
  1898. + // Inlinable fast-path check if Diagnositcs is enabled
  1899. + if (diagnosticListener.IsEnabled())
  1900. {
  1901. - diagnosticSource.Write(
  1902. + AfterOnPageHandlerExecutionImpl(diagnosticListener, handlerExecutedContext, filter);
  1903. + }
  1904. + }
  1905. +
  1906. + private static void AfterOnPageHandlerExecutionImpl(DiagnosticListener diagnosticListener, PageHandlerExecutedContext handlerExecutedContext, IAsyncPageFilter filter)
  1907. + {
  1908. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecution"))
  1909. + {
  1910. + diagnosticListener.Write(
  1911. "Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecution",
  1912. new
  1913. {
  1914. @@ -111,17 +147,26 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
  1915. }
  1916. public static void BeforeOnPageHandlerExecuting(
  1917. - this DiagnosticSource diagnosticSource,
  1918. + this DiagnosticListener diagnosticListener,
  1919. PageHandlerExecutingContext handlerExecutingContext,
  1920. IPageFilter filter)
  1921. {
  1922. - Debug.Assert(diagnosticSource != null);
  1923. + Debug.Assert(diagnosticListener != null);
  1924. Debug.Assert(handlerExecutingContext != null);
  1925. Debug.Assert(filter != null);
  1926. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecuting"))
  1927. + // Inlinable fast-path check if Diagnositcs is enabled
  1928. + if (diagnosticListener.IsEnabled())
  1929. {
  1930. - diagnosticSource.Write(
  1931. + BeforeOnPageHandlerExecutingImpl(diagnosticListener, handlerExecutingContext, filter);
  1932. + }
  1933. + }
  1934. +
  1935. + private static void BeforeOnPageHandlerExecutingImpl(DiagnosticListener diagnosticListener, PageHandlerExecutingContext handlerExecutingContext, IPageFilter filter)
  1936. + {
  1937. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecuting"))
  1938. + {
  1939. + diagnosticListener.Write(
  1940. "Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecuting",
  1941. new
  1942. {
  1943. @@ -133,17 +178,26 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
  1944. }
  1945. public static void AfterOnPageHandlerExecuting(
  1946. - this DiagnosticSource diagnosticSource,
  1947. + this DiagnosticListener diagnosticListener,
  1948. PageHandlerExecutingContext handlerExecutingContext,
  1949. IPageFilter filter)
  1950. {
  1951. - Debug.Assert(diagnosticSource != null);
  1952. + Debug.Assert(diagnosticListener != null);
  1953. Debug.Assert(handlerExecutingContext != null);
  1954. Debug.Assert(filter != null);
  1955. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecuting"))
  1956. + // Inlinable fast-path check if Diagnositcs is enabled
  1957. + if (diagnosticListener.IsEnabled())
  1958. + {
  1959. + AfterOnPageHandlerExecutingImpl(diagnosticListener, handlerExecutingContext, filter);
  1960. + }
  1961. + }
  1962. +
  1963. + private static void AfterOnPageHandlerExecutingImpl(DiagnosticListener diagnosticListener, PageHandlerExecutingContext handlerExecutingContext, IPageFilter filter)
  1964. + {
  1965. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecuting"))
  1966. {
  1967. - diagnosticSource.Write(
  1968. + diagnosticListener.Write(
  1969. "Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecuting",
  1970. new
  1971. {
  1972. @@ -155,17 +209,26 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
  1973. }
  1974. public static void BeforeOnPageHandlerExecuted(
  1975. - this DiagnosticSource diagnosticSource,
  1976. + this DiagnosticListener diagnosticListener,
  1977. PageHandlerExecutedContext handlerExecutedContext,
  1978. IPageFilter filter)
  1979. {
  1980. - Debug.Assert(diagnosticSource != null);
  1981. + Debug.Assert(diagnosticListener != null);
  1982. Debug.Assert(handlerExecutedContext != null);
  1983. Debug.Assert(filter != null);
  1984. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecuted"))
  1985. + // Inlinable fast-path check if Diagnositcs is enabled
  1986. + if (diagnosticListener.IsEnabled())
  1987. {
  1988. - diagnosticSource.Write(
  1989. + BeforeOnPageHandlerExecutedImpl(diagnosticListener, handlerExecutedContext, filter);
  1990. + }
  1991. + }
  1992. +
  1993. + private static void BeforeOnPageHandlerExecutedImpl(DiagnosticListener diagnosticListener, PageHandlerExecutedContext handlerExecutedContext, IPageFilter filter)
  1994. + {
  1995. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecuted"))
  1996. + {
  1997. + diagnosticListener.Write(
  1998. "Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerExecuted",
  1999. new
  2000. {
  2001. @@ -177,17 +240,26 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
  2002. }
  2003. public static void AfterOnPageHandlerExecuted(
  2004. - this DiagnosticSource diagnosticSource,
  2005. + this DiagnosticListener diagnosticListener,
  2006. PageHandlerExecutedContext handlerExecutedContext,
  2007. IPageFilter filter)
  2008. {
  2009. - Debug.Assert(diagnosticSource != null);
  2010. + Debug.Assert(diagnosticListener != null);
  2011. Debug.Assert(handlerExecutedContext != null);
  2012. Debug.Assert(filter != null);
  2013. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecuted"))
  2014. + // Inlinable fast-path check if Diagnositcs is enabled
  2015. + if (diagnosticListener.IsEnabled())
  2016. {
  2017. - diagnosticSource.Write(
  2018. + AfterOnPageHandlerExecutedImpl(diagnosticListener, handlerExecutedContext, filter);
  2019. + }
  2020. + }
  2021. +
  2022. + private static void AfterOnPageHandlerExecutedImpl(DiagnosticListener diagnosticListener, PageHandlerExecutedContext handlerExecutedContext, IPageFilter filter)
  2023. + {
  2024. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecuted"))
  2025. + {
  2026. + diagnosticListener.Write(
  2027. "Microsoft.AspNetCore.Mvc.AfterOnPageHandlerExecuted",
  2028. new
  2029. {
  2030. @@ -199,17 +271,26 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
  2031. }
  2032. public static void BeforeOnPageHandlerSelection(
  2033. - this DiagnosticSource diagnosticSource,
  2034. + this DiagnosticListener diagnosticListener,
  2035. PageHandlerSelectedContext handlerSelectedContext,
  2036. IAsyncPageFilter filter)
  2037. {
  2038. - Debug.Assert(diagnosticSource != null);
  2039. + Debug.Assert(diagnosticListener != null);
  2040. Debug.Assert(handlerSelectedContext != null);
  2041. Debug.Assert(filter != null);
  2042. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerSelection"))
  2043. + // Inlinable fast-path check if Diagnositcs is enabled
  2044. + if (diagnosticListener.IsEnabled())
  2045. + {
  2046. + BeforeOnPageHandlerSelectionImpl(diagnosticListener, handlerSelectedContext, filter);
  2047. + }
  2048. + }
  2049. +
  2050. + private static void BeforeOnPageHandlerSelectionImpl(DiagnosticListener diagnosticListener, PageHandlerSelectedContext handlerSelectedContext, IAsyncPageFilter filter)
  2051. + {
  2052. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerSelection"))
  2053. {
  2054. - diagnosticSource.Write(
  2055. + diagnosticListener.Write(
  2056. "Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerSelection",
  2057. new
  2058. {
  2059. @@ -221,17 +302,26 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
  2060. }
  2061. public static void AfterOnPageHandlerSelection(
  2062. - this DiagnosticSource diagnosticSource,
  2063. + this DiagnosticListener diagnosticListener,
  2064. PageHandlerSelectedContext handlerSelectedContext,
  2065. IAsyncPageFilter filter)
  2066. {
  2067. - Debug.Assert(diagnosticSource != null);
  2068. + Debug.Assert(diagnosticListener != null);
  2069. Debug.Assert(handlerSelectedContext != null);
  2070. Debug.Assert(filter != null);
  2071. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerSelection"))
  2072. + // Inlinable fast-path check if Diagnositcs is enabled
  2073. + if (diagnosticListener.IsEnabled())
  2074. {
  2075. - diagnosticSource.Write(
  2076. + AfterOnPageHandlerSelectionImpl(diagnosticListener, handlerSelectedContext, filter);
  2077. + }
  2078. + }
  2079. +
  2080. + private static void AfterOnPageHandlerSelectionImpl(DiagnosticListener diagnosticListener, PageHandlerSelectedContext handlerSelectedContext, IAsyncPageFilter filter)
  2081. + {
  2082. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerSelection"))
  2083. + {
  2084. + diagnosticListener.Write(
  2085. "Microsoft.AspNetCore.Mvc.AfterOnPageHandlerSelection",
  2086. new
  2087. {
  2088. @@ -243,17 +333,26 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
  2089. }
  2090. public static void BeforeOnPageHandlerSelected(
  2091. - this DiagnosticSource diagnosticSource,
  2092. + this DiagnosticListener diagnosticListener,
  2093. PageHandlerSelectedContext handlerSelectedContext,
  2094. IPageFilter filter)
  2095. {
  2096. - Debug.Assert(diagnosticSource != null);
  2097. + Debug.Assert(diagnosticListener != null);
  2098. Debug.Assert(handlerSelectedContext != null);
  2099. Debug.Assert(filter != null);
  2100. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerSelected"))
  2101. + // Inlinable fast-path check if Diagnositcs is enabled
  2102. + if (diagnosticListener.IsEnabled())
  2103. {
  2104. - diagnosticSource.Write(
  2105. + BeforeOnPageHandlerSelectedImpl(diagnosticListener, handlerSelectedContext, filter);
  2106. + }
  2107. + }
  2108. +
  2109. + private static void BeforeOnPageHandlerSelectedImpl(DiagnosticListener diagnosticListener, PageHandlerSelectedContext handlerSelectedContext, IPageFilter filter)
  2110. + {
  2111. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerSelected"))
  2112. + {
  2113. + diagnosticListener.Write(
  2114. "Microsoft.AspNetCore.Mvc.BeforeOnPageHandlerSelected",
  2115. new
  2116. {
  2117. @@ -265,17 +364,26 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages
  2118. }
  2119. public static void AfterOnPageHandlerSelected(
  2120. - this DiagnosticSource diagnosticSource,
  2121. + this DiagnosticListener diagnosticListener,
  2122. PageHandlerSelectedContext handlerSelectedContext,
  2123. IPageFilter filter)
  2124. {
  2125. - Debug.Assert(diagnosticSource != null);
  2126. + Debug.Assert(diagnosticListener != null);
  2127. Debug.Assert(handlerSelectedContext != null);
  2128. Debug.Assert(filter != null);
  2129. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerSelected"))
  2130. + // Inlinable fast-path check if Diagnositcs is enabled
  2131. + if (diagnosticListener.IsEnabled())
  2132. + {
  2133. + AfterOnPageHandlerSelectedImpl(diagnosticListener, handlerSelectedContext, filter);
  2134. + }
  2135. + }
  2136. +
  2137. + private static void AfterOnPageHandlerSelectedImpl(DiagnosticListener diagnosticListener, PageHandlerSelectedContext handlerSelectedContext, IPageFilter filter)
  2138. + {
  2139. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterOnPageHandlerSelected"))
  2140. {
  2141. - diagnosticSource.Write(
  2142. + diagnosticListener.Write(
  2143. "Microsoft.AspNetCore.Mvc.AfterOnPageHandlerSelected",
  2144. new
  2145. {
  2146. diff --git a/src/Microsoft.AspNetCore.Mvc.RazorPages/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Mvc.RazorPages/breakingchanges.netcore.json
  2147. new file mode 100644
  2148. index 00000000000..d7ad92ec73a
  2149. --- /dev/null
  2150. +++ b/src/Microsoft.AspNetCore.Mvc.RazorPages/breakingchanges.netcore.json
  2151. @@ -0,0 +1,12 @@
  2152. +[
  2153. + {
  2154. + "TypeId": "public class Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.PageResultExecutor : Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor",
  2155. + "MemberId": "public .ctor(Microsoft.AspNetCore.Mvc.Infrastructure.IHttpResponseStreamWriterFactory writerFactory, Microsoft.AspNetCore.Mvc.ViewEngines.ICompositeViewEngine compositeViewEngine, Microsoft.AspNetCore.Mvc.Razor.IRazorViewEngine razorViewEngine, Microsoft.AspNetCore.Mvc.Razor.IRazorPageActivator razorPageActivator, System.Diagnostics.DiagnosticSource diagnosticSource, System.Text.Encodings.Web.HtmlEncoder htmlEncoder)",
  2156. + "Kind": "Removal"
  2157. + },
  2158. + {
  2159. + "TypeId": "public class Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure.DefaultPageFactoryProvider : Microsoft.AspNetCore.Mvc.RazorPages.IPageFactoryProvider",
  2160. + "MemberId": "public .ctor(Microsoft.AspNetCore.Mvc.RazorPages.IPageActivatorProvider pageActivator, Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider metadataProvider, Microsoft.AspNetCore.Mvc.Routing.IUrlHelperFactory urlHelperFactory, Microsoft.AspNetCore.Mvc.Rendering.IJsonHelper jsonHelper, System.Diagnostics.DiagnosticSource diagnosticSource, System.Text.Encodings.Web.HtmlEncoder htmlEncoder, Microsoft.AspNetCore.Mvc.ViewFeatures.IModelExpressionProvider modelExpressionProvider)",
  2161. + "Kind": "Removal"
  2162. + }
  2163. +]
  2164. diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/MvcViewFeaturesDiagnosticSourceExtensions.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/MvcViewFeaturesDiagnosticSourceExtensions.cs
  2165. index d62d6d40288..fa237a7d5dc 100644
  2166. --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/MvcViewFeaturesDiagnosticSourceExtensions.cs
  2167. +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/MvcViewFeaturesDiagnosticSourceExtensions.cs
  2168. @@ -12,13 +12,22 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  2169. internal static class MvcViewFeaturesDiagnosticSourceExtensions
  2170. {
  2171. public static void BeforeViewComponent(
  2172. - this DiagnosticSource diagnosticSource,
  2173. + this DiagnosticListener diagnosticListener,
  2174. ViewComponentContext context,
  2175. object viewComponent)
  2176. {
  2177. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeViewComponent"))
  2178. + // Inlinable fast-path check if Diagnositcs is enabled
  2179. + if (diagnosticListener.IsEnabled())
  2180. {
  2181. - diagnosticSource.Write(
  2182. + BeforeViewComponentImpl(diagnosticListener, context, viewComponent);
  2183. + }
  2184. + }
  2185. +
  2186. + private static void BeforeViewComponentImpl(DiagnosticListener diagnosticListener, ViewComponentContext context, object viewComponent)
  2187. + {
  2188. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeViewComponent"))
  2189. + {
  2190. + diagnosticListener.Write(
  2191. "Microsoft.AspNetCore.Mvc.BeforeViewComponent",
  2192. new
  2193. {
  2194. @@ -30,14 +39,23 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  2195. }
  2196. public static void AfterViewComponent(
  2197. - this DiagnosticSource diagnosticSource,
  2198. + this DiagnosticListener diagnosticListener,
  2199. ViewComponentContext context,
  2200. IViewComponentResult result,
  2201. object viewComponent)
  2202. {
  2203. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterViewComponent"))
  2204. + // Inlinable fast-path check if Diagnositcs is enabled
  2205. + if (diagnosticListener.IsEnabled())
  2206. + {
  2207. + AfterViewComponentImpl(diagnosticListener, context, result, viewComponent);
  2208. + }
  2209. + }
  2210. +
  2211. + private static void AfterViewComponentImpl(DiagnosticListener diagnosticListener, ViewComponentContext context, IViewComponentResult result, object viewComponent)
  2212. + {
  2213. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterViewComponent"))
  2214. {
  2215. - diagnosticSource.Write(
  2216. + diagnosticListener.Write(
  2217. "Microsoft.AspNetCore.Mvc.AfterViewComponent",
  2218. new
  2219. {
  2220. @@ -50,13 +68,22 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  2221. }
  2222. public static void ViewComponentBeforeViewExecute(
  2223. - this DiagnosticSource diagnosticSource,
  2224. + this DiagnosticListener diagnosticListener,
  2225. ViewComponentContext context,
  2226. IView view)
  2227. {
  2228. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.ViewComponentBeforeViewExecute"))
  2229. + // Inlinable fast-path check if Diagnositcs is enabled
  2230. + if (diagnosticListener.IsEnabled())
  2231. {
  2232. - diagnosticSource.Write(
  2233. + ViewComponentBeforeViewExecuteImpl(diagnosticListener, context, view);
  2234. + }
  2235. + }
  2236. +
  2237. + private static void ViewComponentBeforeViewExecuteImpl(DiagnosticListener diagnosticListener, ViewComponentContext context, IView view)
  2238. + {
  2239. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.ViewComponentBeforeViewExecute"))
  2240. + {
  2241. + diagnosticListener.Write(
  2242. "Microsoft.AspNetCore.Mvc.ViewComponentBeforeViewExecute",
  2243. new
  2244. {
  2245. @@ -68,13 +95,22 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  2246. }
  2247. public static void ViewComponentAfterViewExecute(
  2248. - this DiagnosticSource diagnosticSource,
  2249. + this DiagnosticListener diagnosticListener,
  2250. ViewComponentContext context,
  2251. IView view)
  2252. {
  2253. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.ViewComponentAfterViewExecute"))
  2254. + // Inlinable fast-path check if Diagnositcs is enabled
  2255. + if (diagnosticListener.IsEnabled())
  2256. + {
  2257. + ViewComponentAfterViewExecuteImpl(diagnosticListener, context, view);
  2258. + }
  2259. + }
  2260. +
  2261. + private static void ViewComponentAfterViewExecuteImpl(DiagnosticListener diagnosticListener, ViewComponentContext context, IView view)
  2262. + {
  2263. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.ViewComponentAfterViewExecute"))
  2264. {
  2265. - diagnosticSource.Write(
  2266. + diagnosticListener.Write(
  2267. "Microsoft.AspNetCore.Mvc.ViewComponentAfterViewExecute",
  2268. new
  2269. {
  2270. @@ -86,42 +122,69 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  2271. }
  2272. public static void BeforeView(
  2273. - this DiagnosticSource diagnosticSource,
  2274. + this DiagnosticListener diagnosticListener,
  2275. IView view,
  2276. ViewContext viewContext)
  2277. {
  2278. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeView"))
  2279. + // Inlinable fast-path check if Diagnositcs is enabled
  2280. + if (diagnosticListener.IsEnabled())
  2281. {
  2282. - diagnosticSource.Write(
  2283. + BeforeViewImpl(diagnosticListener, view, viewContext);
  2284. + }
  2285. + }
  2286. +
  2287. + private static void BeforeViewImpl(DiagnosticListener diagnosticListener, IView view, ViewContext viewContext)
  2288. + {
  2289. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.BeforeView"))
  2290. + {
  2291. + diagnosticListener.Write(
  2292. "Microsoft.AspNetCore.Mvc.BeforeView",
  2293. new { view = view, viewContext = viewContext, });
  2294. }
  2295. }
  2296. public static void AfterView(
  2297. - this DiagnosticSource diagnosticSource,
  2298. + this DiagnosticListener diagnosticListener,
  2299. IView view,
  2300. ViewContext viewContext)
  2301. {
  2302. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.AfterView"))
  2303. + // Inlinable fast-path check if Diagnositcs is enabled
  2304. + if (diagnosticListener.IsEnabled())
  2305. + {
  2306. + AfterViewImpl(diagnosticListener, view, viewContext);
  2307. + }
  2308. + }
  2309. +
  2310. + private static void AfterViewImpl(DiagnosticListener diagnosticListener, IView view, ViewContext viewContext)
  2311. + {
  2312. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.AfterView"))
  2313. {
  2314. - diagnosticSource.Write(
  2315. + diagnosticListener.Write(
  2316. "Microsoft.AspNetCore.Mvc.AfterView",
  2317. new { view = view, viewContext = viewContext, });
  2318. }
  2319. }
  2320. public static void ViewFound(
  2321. - this DiagnosticSource diagnosticSource,
  2322. + this DiagnosticListener diagnosticListener,
  2323. ActionContext actionContext,
  2324. bool isMainPage,
  2325. PartialViewResult viewResult,
  2326. string viewName,
  2327. IView view)
  2328. {
  2329. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.ViewFound"))
  2330. + // Inlinable fast-path check if Diagnositcs is enabled
  2331. + if (diagnosticListener.IsEnabled())
  2332. {
  2333. - diagnosticSource.Write(
  2334. + ViewFoundImpl(diagnosticListener, actionContext, isMainPage, viewResult, viewName, view);
  2335. + }
  2336. + }
  2337. +
  2338. + private static void ViewFoundImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, bool isMainPage, PartialViewResult viewResult, string viewName, IView view)
  2339. + {
  2340. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.ViewFound"))
  2341. + {
  2342. + diagnosticListener.Write(
  2343. "Microsoft.AspNetCore.Mvc.ViewFound",
  2344. new
  2345. {
  2346. @@ -135,16 +198,25 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  2347. }
  2348. public static void ViewNotFound(
  2349. - this DiagnosticSource diagnosticSource,
  2350. + this DiagnosticListener diagnosticListener,
  2351. ActionContext actionContext,
  2352. bool isMainPage,
  2353. PartialViewResult viewResult,
  2354. string viewName,
  2355. IEnumerable<string> searchedLocations)
  2356. {
  2357. - if (diagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.ViewNotFound"))
  2358. + // Inlinable fast-path check if Diagnositcs is enabled
  2359. + if (diagnosticListener.IsEnabled())
  2360. + {
  2361. + ViewNotFoundImpl(diagnosticListener, actionContext, isMainPage, viewResult, viewName, searchedLocations);
  2362. + }
  2363. + }
  2364. +
  2365. + private static void ViewNotFoundImpl(DiagnosticListener diagnosticListener, ActionContext actionContext, bool isMainPage, PartialViewResult viewResult, string viewName, IEnumerable<string> searchedLocations)
  2366. + {
  2367. + if (diagnosticListener.IsEnabled("Microsoft.AspNetCore.Mvc.ViewNotFound"))
  2368. {
  2369. - diagnosticSource.Write(
  2370. + diagnosticListener.Write(
  2371. "Microsoft.AspNetCore.Mvc.ViewNotFound",
  2372. new
  2373. {
  2374. diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/PartialViewResultExecutor.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/PartialViewResultExecutor.cs
  2375. index 39bcf58369f..18476d70086 100644
  2376. --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/PartialViewResultExecutor.cs
  2377. +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/PartialViewResultExecutor.cs
  2378. @@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  2379. /// <param name="writerFactory">The <see cref="IHttpResponseStreamWriterFactory"/>.</param>
  2380. /// <param name="viewEngine">The <see cref="ICompositeViewEngine"/>.</param>
  2381. /// <param name="tempDataFactory">The <see cref="ITempDataDictionaryFactory"/>.</param>
  2382. - /// <param name="diagnosticSource">The <see cref="DiagnosticSource"/>.</param>
  2383. + /// <param name="diagnosticListener">The <see cref="DiagnosticListener"/>.</param>
  2384. /// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param>
  2385. /// <param name="modelMetadataProvider">The <see cref="IModelMetadataProvider"/>.</param>
  2386. public PartialViewResultExecutor(
  2387. @@ -38,10 +38,10 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  2388. IHttpResponseStreamWriterFactory writerFactory,
  2389. ICompositeViewEngine viewEngine,
  2390. ITempDataDictionaryFactory tempDataFactory,
  2391. - DiagnosticSource diagnosticSource,
  2392. + DiagnosticListener diagnosticListener,
  2393. ILoggerFactory loggerFactory,
  2394. IModelMetadataProvider modelMetadataProvider)
  2395. - : base(viewOptions, writerFactory, viewEngine, tempDataFactory, diagnosticSource, modelMetadataProvider)
  2396. + : base(viewOptions, writerFactory, viewEngine, tempDataFactory, diagnosticListener, modelMetadataProvider)
  2397. {
  2398. if (loggerFactory == null)
  2399. {
  2400. diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/DefaultViewComponentInvoker.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/DefaultViewComponentInvoker.cs
  2401. index 5fdb90b505f..15d0018ec10 100644
  2402. --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/DefaultViewComponentInvoker.cs
  2403. +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/DefaultViewComponentInvoker.cs
  2404. @@ -19,7 +19,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
  2405. {
  2406. private readonly IViewComponentFactory _viewComponentFactory;
  2407. private readonly ViewComponentInvokerCache _viewComponentInvokerCache;
  2408. - private readonly DiagnosticSource _diagnosticSource;
  2409. + private readonly DiagnosticListener _diagnosticListener;
  2410. private readonly ILogger _logger;
  2411. /// <summary>
  2412. @@ -27,12 +27,12 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
  2413. /// </summary>
  2414. /// <param name="viewComponentFactory">The <see cref="IViewComponentFactory"/>.</param>
  2415. /// <param name="viewComponentInvokerCache">The <see cref="ViewComponentInvokerCache"/>.</param>
  2416. - /// <param name="diagnosticSource">The <see cref="DiagnosticSource"/>.</param>
  2417. + /// <param name="diagnosticListener">The <see cref="DiagnosticListener"/>.</param>
  2418. /// <param name="logger">The <see cref="ILogger"/>.</param>
  2419. public DefaultViewComponentInvoker(
  2420. IViewComponentFactory viewComponentFactory,
  2421. ViewComponentInvokerCache viewComponentInvokerCache,
  2422. - DiagnosticSource diagnosticSource,
  2423. + DiagnosticListener diagnosticListener,
  2424. ILogger logger)
  2425. {
  2426. if (viewComponentFactory == null)
  2427. @@ -45,9 +45,9 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
  2428. throw new ArgumentNullException(nameof(viewComponentInvokerCache));
  2429. }
  2430. - if (diagnosticSource == null)
  2431. + if (diagnosticListener == null)
  2432. {
  2433. - throw new ArgumentNullException(nameof(diagnosticSource));
  2434. + throw new ArgumentNullException(nameof(diagnosticListener));
  2435. }
  2436. if (logger == null)
  2437. @@ -57,7 +57,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
  2438. _viewComponentFactory = viewComponentFactory;
  2439. _viewComponentInvokerCache = viewComponentInvokerCache;
  2440. - _diagnosticSource = diagnosticSource;
  2441. + _diagnosticListener = diagnosticListener;
  2442. _logger = logger;
  2443. }
  2444. @@ -101,7 +101,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
  2445. {
  2446. var arguments = PrepareArguments(context.Arguments, executor);
  2447. - _diagnosticSource.BeforeViewComponent(context, component);
  2448. + _diagnosticListener.BeforeViewComponent(context, component);
  2449. _logger.ViewComponentExecuting(context, arguments);
  2450. var stopwatch = ValueStopwatch.StartNew();
  2451. @@ -128,7 +128,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
  2452. var viewComponentResult = CoerceToViewComponentResult(resultAsObject);
  2453. _logger.ViewComponentExecuted(context, stopwatch.GetElapsedTime(), viewComponentResult);
  2454. - _diagnosticSource.AfterViewComponent(context, viewComponentResult, component);
  2455. + _diagnosticListener.AfterViewComponent(context, viewComponentResult, component);
  2456. _viewComponentFactory.ReleaseViewComponent(context, component);
  2457. @@ -144,7 +144,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
  2458. {
  2459. var arguments = PrepareArguments(context.Arguments, executor);
  2460. - _diagnosticSource.BeforeViewComponent(context, component);
  2461. + _diagnosticListener.BeforeViewComponent(context, component);
  2462. _logger.ViewComponentExecuting(context, arguments);
  2463. var stopwatch = ValueStopwatch.StartNew();
  2464. @@ -161,7 +161,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
  2465. var viewComponentResult = CoerceToViewComponentResult(result);
  2466. _logger.ViewComponentExecuted(context, stopwatch.GetElapsedTime(), viewComponentResult);
  2467. - _diagnosticSource.AfterViewComponent(context, viewComponentResult, component);
  2468. + _diagnosticListener.AfterViewComponent(context, viewComponentResult, component);
  2469. _viewComponentFactory.ReleaseViewComponent(context, component);
  2470. diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/DefaultViewComponentInvokerFactory.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/DefaultViewComponentInvokerFactory.cs
  2471. index de1740f21c6..d620357be20 100644
  2472. --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/DefaultViewComponentInvokerFactory.cs
  2473. +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/DefaultViewComponentInvokerFactory.cs
  2474. @@ -12,12 +12,12 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
  2475. private readonly IViewComponentFactory _viewComponentFactory;
  2476. private readonly ViewComponentInvokerCache _viewComponentInvokerCache;
  2477. private readonly ILogger _logger;
  2478. - private readonly DiagnosticSource _diagnosticSource;
  2479. + private readonly DiagnosticListener _diagnosticListener;
  2480. public DefaultViewComponentInvokerFactory(
  2481. IViewComponentFactory viewComponentFactory,
  2482. ViewComponentInvokerCache viewComponentInvokerCache,
  2483. - DiagnosticSource diagnosticSource,
  2484. + DiagnosticListener diagnosticListener,
  2485. ILoggerFactory loggerFactory)
  2486. {
  2487. if (viewComponentFactory == null)
  2488. @@ -30,9 +30,9 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
  2489. throw new ArgumentNullException(nameof(viewComponentInvokerCache));
  2490. }
  2491. - if (diagnosticSource == null)
  2492. + if (diagnosticListener == null)
  2493. {
  2494. - throw new ArgumentNullException(nameof(diagnosticSource));
  2495. + throw new ArgumentNullException(nameof(diagnosticListener));
  2496. }
  2497. if (loggerFactory == null)
  2498. @@ -41,7 +41,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
  2499. }
  2500. _viewComponentFactory = viewComponentFactory;
  2501. - _diagnosticSource = diagnosticSource;
  2502. + _diagnosticListener = diagnosticListener;
  2503. _viewComponentInvokerCache = viewComponentInvokerCache;
  2504. _logger = loggerFactory.CreateLogger<DefaultViewComponentInvoker>();
  2505. @@ -61,7 +61,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
  2506. return new DefaultViewComponentInvoker(
  2507. _viewComponentFactory,
  2508. _viewComponentInvokerCache,
  2509. - _diagnosticSource,
  2510. + _diagnosticListener,
  2511. _logger);
  2512. }
  2513. }
  2514. diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/ViewViewComponentResult.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/ViewViewComponentResult.cs
  2515. index bf7ff1f7f35..e9196c5a183 100644
  2516. --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/ViewViewComponentResult.cs
  2517. +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewComponents/ViewViewComponentResult.cs
  2518. @@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
  2519. private const string ViewPathFormat = "Components/{0}/{1}";
  2520. private const string DefaultViewName = "Default";
  2521. - private DiagnosticSource _diagnosticSource;
  2522. + private DiagnosticListener _diagnosticListener;
  2523. /// <summary>
  2524. /// Gets or sets the view name.
  2525. @@ -115,12 +115,12 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
  2526. var view = result.EnsureSuccessful(originalLocations).View;
  2527. using (view as IDisposable)
  2528. {
  2529. - if (_diagnosticSource == null)
  2530. + if (_diagnosticListener == null)
  2531. {
  2532. - _diagnosticSource = viewContext.HttpContext.RequestServices.GetRequiredService<DiagnosticSource>();
  2533. + _diagnosticListener = viewContext.HttpContext.RequestServices.GetRequiredService<DiagnosticListener>();
  2534. }
  2535. - _diagnosticSource.ViewComponentBeforeViewExecute(context, view);
  2536. + _diagnosticListener.ViewComponentBeforeViewExecute(context, view);
  2537. var childViewContext = new ViewContext(
  2538. viewContext,
  2539. @@ -129,7 +129,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewComponents
  2540. context.Writer);
  2541. await view.RenderAsync(childViewContext);
  2542. - _diagnosticSource.ViewComponentAfterViewExecute(context, view);
  2543. + _diagnosticListener.ViewComponentAfterViewExecute(context, view);
  2544. }
  2545. }
  2546. diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewExecutor.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewExecutor.cs
  2547. index e815f386d8e..5ac1031f560 100644
  2548. --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewExecutor.cs
  2549. +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewExecutor.cs
  2550. @@ -32,16 +32,16 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  2551. /// <param name="writerFactory">The <see cref="IHttpResponseStreamWriterFactory"/>.</param>
  2552. /// <param name="viewEngine">The <see cref="ICompositeViewEngine"/>.</param>
  2553. /// <param name="tempDataFactory">The <see cref="ITempDataDictionaryFactory"/>.</param>
  2554. - /// <param name="diagnosticSource">The <see cref="DiagnosticSource"/>.</param>
  2555. + /// <param name="diagnosticListener">The <see cref="DiagnosticSource"/>.</param>
  2556. /// <param name="modelMetadataProvider">The <see cref="IModelMetadataProvider" />.</param>
  2557. public ViewExecutor(
  2558. IOptions<MvcViewOptions> viewOptions,
  2559. IHttpResponseStreamWriterFactory writerFactory,
  2560. ICompositeViewEngine viewEngine,
  2561. ITempDataDictionaryFactory tempDataFactory,
  2562. - DiagnosticSource diagnosticSource,
  2563. + DiagnosticListener diagnosticListener,
  2564. IModelMetadataProvider modelMetadataProvider)
  2565. - : this(writerFactory, viewEngine, diagnosticSource)
  2566. + : this(writerFactory, viewEngine, diagnosticListener)
  2567. {
  2568. if (viewOptions == null)
  2569. {
  2570. @@ -53,9 +53,9 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  2571. throw new ArgumentNullException(nameof(tempDataFactory));
  2572. }
  2573. - if (diagnosticSource == null)
  2574. + if (diagnosticListener == null)
  2575. {
  2576. - throw new ArgumentNullException(nameof(diagnosticSource));
  2577. + throw new ArgumentNullException(nameof(diagnosticListener));
  2578. }
  2579. ViewOptions = viewOptions.Value;
  2580. @@ -68,11 +68,11 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  2581. /// </summary>
  2582. /// <param name="writerFactory">The <see cref="IHttpResponseStreamWriterFactory"/>.</param>
  2583. /// <param name="viewEngine">The <see cref="ICompositeViewEngine"/>.</param>
  2584. - /// <param name="diagnosticSource">The <see cref="System.Diagnostics.DiagnosticSource"/>.</param>
  2585. + /// <param name="diagnosticListener">The <see cref="System.Diagnostics.DiagnosticListener"/>.</param>
  2586. protected ViewExecutor(
  2587. IHttpResponseStreamWriterFactory writerFactory,
  2588. ICompositeViewEngine viewEngine,
  2589. - DiagnosticSource diagnosticSource)
  2590. + DiagnosticListener diagnosticListener)
  2591. {
  2592. if (writerFactory == null)
  2593. {
  2594. @@ -84,20 +84,20 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  2595. throw new ArgumentNullException(nameof(viewEngine));
  2596. }
  2597. - if (diagnosticSource == null)
  2598. + if (diagnosticListener == null)
  2599. {
  2600. - throw new ArgumentNullException(nameof(diagnosticSource));
  2601. + throw new ArgumentNullException(nameof(diagnosticListener));
  2602. }
  2603. WriterFactory = writerFactory;
  2604. ViewEngine = viewEngine;
  2605. - DiagnosticSource = diagnosticSource;
  2606. + DiagnosticSource = diagnosticListener;
  2607. }
  2608. /// <summary>
  2609. /// Gets the <see cref="DiagnosticSource"/>.
  2610. /// </summary>
  2611. - protected DiagnosticSource DiagnosticSource { get; }
  2612. + protected DiagnosticListener DiagnosticSource { get; }
  2613. /// <summary>
  2614. /// Gets the <see cref="ITempDataDictionaryFactory"/>.
  2615. diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewResultExecutor.cs b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewResultExecutor.cs
  2616. index f23451992bb..8cc09aac3c7 100644
  2617. --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewResultExecutor.cs
  2618. +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/ViewResultExecutor.cs
  2619. @@ -30,7 +30,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  2620. /// <param name="writerFactory">The <see cref="IHttpResponseStreamWriterFactory"/>.</param>
  2621. /// <param name="viewEngine">The <see cref="ICompositeViewEngine"/>.</param>
  2622. /// <param name="tempDataFactory">The <see cref="ITempDataDictionaryFactory"/>.</param>
  2623. - /// <param name="diagnosticSource">The <see cref="DiagnosticSource"/>.</param>
  2624. + /// <param name="diagnosticListener">The <see cref="DiagnosticListener"/>.</param>
  2625. /// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param>
  2626. /// <param name="modelMetadataProvider">The <see cref="IModelMetadataProvider"/>.</param>
  2627. public ViewResultExecutor(
  2628. @@ -38,10 +38,10 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  2629. IHttpResponseStreamWriterFactory writerFactory,
  2630. ICompositeViewEngine viewEngine,
  2631. ITempDataDictionaryFactory tempDataFactory,
  2632. - DiagnosticSource diagnosticSource,
  2633. + DiagnosticListener diagnosticListener,
  2634. ILoggerFactory loggerFactory,
  2635. IModelMetadataProvider modelMetadataProvider)
  2636. - : base(viewOptions, writerFactory, viewEngine, tempDataFactory, diagnosticSource, modelMetadataProvider)
  2637. + : base(viewOptions, writerFactory, viewEngine, tempDataFactory, diagnosticListener, modelMetadataProvider)
  2638. {
  2639. if (loggerFactory == null)
  2640. {
  2641. @@ -107,6 +107,25 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  2642. }
  2643. }
  2644. + if (DiagnosticSource.IsEnabled())
  2645. + {
  2646. + OutputDiagnostics(actionContext, viewResult, viewName, stopwatch, result);
  2647. + }
  2648. +
  2649. + if (result.Success)
  2650. + {
  2651. + Logger.ViewFound(result.View, stopwatch.GetElapsedTime());
  2652. + }
  2653. + else
  2654. + {
  2655. + Logger.ViewNotFound(viewName, result.SearchedLocations);
  2656. + }
  2657. +
  2658. + return result;
  2659. + }
  2660. +
  2661. + private void OutputDiagnostics(ActionContext actionContext, ViewResult viewResult, string viewName, ValueStopwatch stopwatch, ViewEngineResult result)
  2662. + {
  2663. if (result.Success)
  2664. {
  2665. if (DiagnosticSource.IsEnabled("Microsoft.AspNetCore.Mvc.ViewFound"))
  2666. @@ -122,8 +141,6 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  2667. view = result.View,
  2668. });
  2669. }
  2670. -
  2671. - Logger.ViewFound(result.View, stopwatch.GetElapsedTime());
  2672. }
  2673. else
  2674. {
  2675. @@ -140,10 +157,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  2676. searchedLocations = result.SearchedLocations
  2677. });
  2678. }
  2679. - Logger.ViewNotFound(viewName, result.SearchedLocations);
  2680. }
  2681. -
  2682. - return result;
  2683. }
  2684. /// <inheritdoc />
  2685. diff --git a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/breakingchanges.netcore.json b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/breakingchanges.netcore.json
  2686. index 638cfe4f77f..0cbd0490d65 100644
  2687. --- a/src/Microsoft.AspNetCore.Mvc.ViewFeatures/breakingchanges.netcore.json
  2688. +++ b/src/Microsoft.AspNetCore.Mvc.ViewFeatures/breakingchanges.netcore.json
  2689. @@ -1,16 +1,30 @@
  2690. [
  2691. + {
  2692. + "TypeId": "public class Microsoft.AspNetCore.Mvc.RemoteAttribute : System.ComponentModel.DataAnnotations.ValidationAttribute, Microsoft.AspNetCore.Mvc.ModelBinding.Validation.IClientModelValidator",
  2693. + "Kind": "Removal"
  2694. + },
  2695. {
  2696. "TypeId": "public class Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionaryControllerPropertyActivator : Microsoft.AspNetCore.Mvc.Internal.IControllerPropertyActivator",
  2697. "Kind": "Removal"
  2698. },
  2699. {
  2700. - "TypeId": "public class Microsoft.AspNetCore.Mvc.ViewComponents.DefaultViewComponentActivator : Microsoft.AspNetCore.Mvc.ViewComponents.IViewComponentActivator",
  2701. - "MemberId": "public .ctor(Microsoft.AspNetCore.Mvc.Internal.ITypeActivatorCache typeActivatorCache)",
  2702. + "TypeId": "public class Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor",
  2703. + "MemberId": "protected .ctor(Microsoft.AspNetCore.Mvc.Infrastructure.IHttpResponseStreamWriterFactory writerFactory, Microsoft.AspNetCore.Mvc.ViewEngines.ICompositeViewEngine viewEngine, System.Diagnostics.DiagnosticSource diagnosticSource)",
  2704. "Kind": "Removal"
  2705. },
  2706. {
  2707. - "TypeId": "public class Microsoft.AspNetCore.Mvc.ViewFeatures.DefaultValidationHtmlAttributeProvider : Microsoft.AspNetCore.Mvc.ViewFeatures.ValidationHtmlAttributeProvider",
  2708. - "MemberId": "public .ctor(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Mvc.MvcViewOptions> optionsAccessor, Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider metadataProvider, Microsoft.AspNetCore.Mvc.Internal.ClientValidatorCache clientValidatorCache)",
  2709. + "TypeId": "public class Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor",
  2710. + "MemberId": "protected System.Diagnostics.DiagnosticSource get_DiagnosticSource()",
  2711. + "Kind": "Removal"
  2712. + },
  2713. + {
  2714. + "TypeId": "public class Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor",
  2715. + "MemberId": "public .ctor(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Mvc.MvcViewOptions> viewOptions, Microsoft.AspNetCore.Mvc.Infrastructure.IHttpResponseStreamWriterFactory writerFactory, Microsoft.AspNetCore.Mvc.ViewEngines.ICompositeViewEngine viewEngine, Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory tempDataFactory, System.Diagnostics.DiagnosticSource diagnosticSource, Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider modelMetadataProvider)",
  2716. + "Kind": "Removal"
  2717. + },
  2718. + {
  2719. + "TypeId": "public class Microsoft.AspNetCore.Mvc.ViewComponents.DefaultViewComponentActivator : Microsoft.AspNetCore.Mvc.ViewComponents.IViewComponentActivator",
  2720. + "MemberId": "public .ctor(Microsoft.AspNetCore.Mvc.Internal.ITypeActivatorCache typeActivatorCache)",
  2721. "Kind": "Removal"
  2722. },
  2723. {
  2724. @@ -44,7 +58,18 @@
  2725. "Kind": "Removal"
  2726. },
  2727. {
  2728. - "TypeId": "public class Microsoft.AspNetCore.Mvc.RemoteAttribute : System.ComponentModel.DataAnnotations.ValidationAttribute, Microsoft.AspNetCore.Mvc.ModelBinding.Validation.IClientModelValidator",
  2729. - "Kind": "Removal"
  2730. + "TypeId": "public class Microsoft.AspNetCore.Mvc.ViewFeatures.DefaultValidationHtmlAttributeProvider : Microsoft.AspNetCore.Mvc.ViewFeatures.ValidationHtmlAttributeProvider",
  2731. + "MemberId": "public .ctor(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Mvc.MvcViewOptions> optionsAccessor, Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider metadataProvider, Microsoft.AspNetCore.Mvc.Internal.ClientValidatorCache clientValidatorCache)",
  2732. + "Kind": "Removal"
  2733. + },
  2734. + {
  2735. + "TypeId": "public class Microsoft.AspNetCore.Mvc.ViewFeatures.PartialViewResultExecutor : Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor, Microsoft.AspNetCore.Mvc.Infrastructure.IActionResultExecutor<Microsoft.AspNetCore.Mvc.PartialViewResult>",
  2736. + "MemberId": "public .ctor(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Mvc.MvcViewOptions> viewOptions, Microsoft.AspNetCore.Mvc.Infrastructure.IHttpResponseStreamWriterFactory writerFactory, Microsoft.AspNetCore.Mvc.ViewEngines.ICompositeViewEngine viewEngine, Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory tempDataFactory, System.Diagnostics.DiagnosticSource diagnosticSource, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider modelMetadataProvider)",
  2737. + "Kind": "Removal"
  2738. + },
  2739. + {
  2740. + "TypeId": "public class Microsoft.AspNetCore.Mvc.ViewFeatures.ViewResultExecutor : Microsoft.AspNetCore.Mvc.ViewFeatures.ViewExecutor, Microsoft.AspNetCore.Mvc.Infrastructure.IActionResultExecutor<Microsoft.AspNetCore.Mvc.ViewResult>",
  2741. + "MemberId": "public .ctor(Microsoft.Extensions.Options.IOptions<Microsoft.AspNetCore.Mvc.MvcViewOptions> viewOptions, Microsoft.AspNetCore.Mvc.Infrastructure.IHttpResponseStreamWriterFactory writerFactory, Microsoft.AspNetCore.Mvc.ViewEngines.ICompositeViewEngine viewEngine, Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory tempDataFactory, System.Diagnostics.DiagnosticSource diagnosticSource, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider modelMetadataProvider)",
  2742. + "Kind": "Removal"
  2743. }
  2744. -]
  2745. \ No newline at end of file
  2746. +]
  2747. diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/Builder/MvcApplicationBuilderExtensionsTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/Builder/MvcApplicationBuilderExtensionsTest.cs
  2748. index 6bceeb51d0f..11e786561b3 100644
  2749. --- a/test/Microsoft.AspNetCore.Mvc.Core.Test/Builder/MvcApplicationBuilderExtensionsTest.cs
  2750. +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/Builder/MvcApplicationBuilderExtensionsTest.cs
  2751. @@ -43,7 +43,7 @@ namespace Microsoft.AspNetCore.Mvc.Core.Builder
  2752. {
  2753. // Arrange
  2754. var services = new ServiceCollection();
  2755. - services.AddSingleton<DiagnosticSource>(new DiagnosticListener("Microsoft.AspNetCore"));
  2756. + services.AddSingleton<DiagnosticListener>(new DiagnosticListener("Microsoft.AspNetCore"));
  2757. services.AddLogging();
  2758. services.AddMvcCore(o => o.EnableEndpointRouting = false);
  2759. var serviceProvider = services.BuildServiceProvider();
  2760. @@ -68,7 +68,7 @@ namespace Microsoft.AspNetCore.Mvc.Core.Builder
  2761. {
  2762. // Arrange
  2763. var services = new ServiceCollection();
  2764. - services.AddSingleton<DiagnosticSource>(new DiagnosticListener("Microsoft.AspNetCore"));
  2765. + services.AddSingleton<DiagnosticListener>(new DiagnosticListener("Microsoft.AspNetCore"));
  2766. services.AddLogging();
  2767. services.AddMvcCore(o => o.EnableEndpointRouting = true);
  2768. var serviceProvider = services.BuildServiceProvider();
  2769. diff --git a/test/Microsoft.AspNetCore.Mvc.Core.Test/Filters/MiddlewareFilterTest.cs b/test/Microsoft.AspNetCore.Mvc.Core.Test/Filters/MiddlewareFilterTest.cs
  2770. index 813c23fe384..8d72ce9a364 100644
  2771. --- a/test/Microsoft.AspNetCore.Mvc.Core.Test/Filters/MiddlewareFilterTest.cs
  2772. +++ b/test/Microsoft.AspNetCore.Mvc.Core.Test/Filters/MiddlewareFilterTest.cs
  2773. @@ -276,14 +276,14 @@ namespace Microsoft.AspNetCore.Mvc.Filters
  2774. var actionContext = new ActionContext(httpContext, new RouteData(), actionDescriptor);
  2775. - var diagnosticSource = new DiagnosticListener("Microsoft.AspNetCore");
  2776. - diagnosticSource.SubscribeWithAdapter(new TestDiagnosticListener());
  2777. + var diagnosticListener = new DiagnosticListener("Microsoft.AspNetCore");
  2778. + diagnosticListener.SubscribeWithAdapter(new TestDiagnosticListener());
  2779. var invoker = new TestControllerActionInvoker(
  2780. filters,
  2781. new MockControllerFactory(controller ?? this),
  2782. new NullLoggerFactory().CreateLogger<ControllerActionInvoker>(),
  2783. - diagnosticSource,
  2784. + diagnosticListener,
  2785. new ActionResultTypeMapper(),
  2786. actionContext,
  2787. new List<IValueProviderFactory>(),
  2788. @@ -388,14 +388,14 @@ namespace Microsoft.AspNetCore.Mvc.Filters
  2789. IFilterMetadata[] filters,
  2790. MockControllerFactory controllerFactory,
  2791. ILogger logger,
  2792. - DiagnosticSource diagnosticSource,
  2793. + DiagnosticListener diagnosticListener,
  2794. IActionResultTypeMapper mapper,
  2795. ActionContext actionContext,
  2796. IReadOnlyList<IValueProviderFactory> valueProviderFactories,
  2797. int maxAllowedErrorsInModelState)
  2798. : base(
  2799. logger,
  2800. - diagnosticSource,
  2801. + diagnosticListener,
  2802. mapper,
  2803. CreateControllerContext(actionContext, valueProviderFactories, maxAllowedErrorsInModelState),
  2804. CreateCacheEntry((ControllerActionDescriptor)actionContext.ActionDescriptor, controllerFactory),
  2805. diff --git a/test/Microsoft.AspNetCore.Mvc.Razor.Test/RazorViewTest.cs b/test/Microsoft.AspNetCore.Mvc.Razor.Test/RazorViewTest.cs
  2806. index 991b1de1b7b..82d010e9cad 100644
  2807. --- a/test/Microsoft.AspNetCore.Mvc.Razor.Test/RazorViewTest.cs
  2808. +++ b/test/Microsoft.AspNetCore.Mvc.Razor.Test/RazorViewTest.cs
  2809. @@ -111,8 +111,8 @@ namespace Microsoft.AspNetCore.Mvc.Razor
  2810. var activator = new Mock<IRazorPageActivator>();
  2811. var adapter = new TestDiagnosticListener();
  2812. - var diagnosticSource = new DiagnosticListener("Microsoft.AspNetCore.Mvc.Razor");
  2813. - diagnosticSource.SubscribeWithAdapter(adapter);
  2814. + var diagnosticListener = new DiagnosticListener("Microsoft.AspNetCore.Mvc.Razor");
  2815. + diagnosticListener.SubscribeWithAdapter(adapter);
  2816. var view = new RazorView(
  2817. Mock.Of<IRazorViewEngine>(),
  2818. @@ -120,7 +120,7 @@ namespace Microsoft.AspNetCore.Mvc.Razor
  2819. new IRazorPage[0],
  2820. page,
  2821. new HtmlTestEncoder(),
  2822. - diagnosticSource);
  2823. + diagnosticListener);
  2824. var viewContext = CreateViewContext(view);
  2825. var expectedWriter = viewContext.Writer;
  2826. diff --git a/test/Microsoft.AspNetCore.Mvc.RazorPages.Test/Infrastructure/DefaultPageFactoryProviderTest.cs b/test/Microsoft.AspNetCore.Mvc.RazorPages.Test/Infrastructure/DefaultPageFactoryProviderTest.cs
  2827. index 6b337a93ebe..9e2871d62ac 100644
  2828. --- a/test/Microsoft.AspNetCore.Mvc.RazorPages.Test/Infrastructure/DefaultPageFactoryProviderTest.cs
  2829. +++ b/test/Microsoft.AspNetCore.Mvc.RazorPages.Test/Infrastructure/DefaultPageFactoryProviderTest.cs
  2830. @@ -294,7 +294,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
  2831. IModelMetadataProvider provider = null,
  2832. IUrlHelperFactory urlHelperFactory = null,
  2833. IJsonHelper jsonHelper = null,
  2834. - DiagnosticSource diagnosticSource = null,
  2835. + DiagnosticListener diagnosticListener = null,
  2836. HtmlEncoder htmlEncoder = null,
  2837. IModelExpressionProvider modelExpressionProvider = null)
  2838. {
  2839. @@ -303,7 +303,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure
  2840. provider ?? Mock.Of<IModelMetadataProvider>(),
  2841. urlHelperFactory ?? Mock.Of<IUrlHelperFactory>(),
  2842. jsonHelper ?? Mock.Of<IJsonHelper>(),
  2843. - diagnosticSource ?? new DiagnosticListener("Microsoft.AspNetCore.Mvc.RazorPages"),
  2844. + diagnosticListener ?? new DiagnosticListener("Microsoft.AspNetCore.Mvc.RazorPages"),
  2845. htmlEncoder ?? HtmlEncoder.Default,
  2846. modelExpressionProvider ?? Mock.Of<IModelExpressionProvider>());
  2847. }
  2848. diff --git a/test/Microsoft.AspNetCore.Mvc.Test/MvcOptionsSetupTest.cs b/test/Microsoft.AspNetCore.Mvc.Test/MvcOptionsSetupTest.cs
  2849. index 1607c35ad1b..29176f09894 100644
  2850. --- a/test/Microsoft.AspNetCore.Mvc.Test/MvcOptionsSetupTest.cs
  2851. +++ b/test/Microsoft.AspNetCore.Mvc.Test/MvcOptionsSetupTest.cs
  2852. @@ -264,7 +264,9 @@ namespace Microsoft.AspNetCore.Mvc
  2853. {
  2854. var serviceCollection = new ServiceCollection();
  2855. serviceCollection.AddSingleton(new ApplicationPartManager());
  2856. - serviceCollection.AddSingleton<DiagnosticSource>(new DiagnosticListener("Microsoft.AspNetCore.Mvc"));
  2857. + var diagnosticListener = new DiagnosticListener("Microsoft.AspNetCore.Mvc");
  2858. + serviceCollection.AddSingleton<DiagnosticSource>(diagnosticListener);
  2859. + serviceCollection.AddSingleton<DiagnosticListener>(diagnosticListener);
  2860. serviceCollection.AddMvc();
  2861. serviceCollection
  2862. .AddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>()
  2863. diff --git a/test/Microsoft.AspNetCore.Mvc.Test/MvcServiceCollectionExtensionsTest.cs b/test/Microsoft.AspNetCore.Mvc.Test/MvcServiceCollectionExtensionsTest.cs
  2864. index 9aecad709cd..498275a1b8a 100644
  2865. --- a/test/Microsoft.AspNetCore.Mvc.Test/MvcServiceCollectionExtensionsTest.cs
  2866. +++ b/test/Microsoft.AspNetCore.Mvc.Test/MvcServiceCollectionExtensionsTest.cs
  2867. @@ -261,7 +261,10 @@ namespace Microsoft.AspNetCore.Mvc
  2868. services.AddSingleton<IHostingEnvironment>(GetHostingEnvironment());
  2869. services.AddSingleton<ObjectPoolProvider, DefaultObjectPoolProvider>();
  2870. - services.AddSingleton<DiagnosticSource>(new DiagnosticListener("Microsoft.AspNet"));
  2871. +
  2872. + var diagnosticListener = new DiagnosticListener("Microsoft.AspNet");
  2873. + services.AddSingleton<DiagnosticSource>(diagnosticListener);
  2874. + services.AddSingleton<DiagnosticListener>(diagnosticListener);
  2875. services.AddSingleton<IConfiguration>(new ConfigurationBuilder().Build());
  2876. services.AddLogging();
  2877. services.AddOptions();
  2878. diff --git a/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/PartialViewResultExecutorTest.cs b/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/PartialViewResultExecutorTest.cs
  2879. index 3a34cc25d20..d3b74704df1 100644
  2880. --- a/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/PartialViewResultExecutorTest.cs
  2881. +++ b/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/PartialViewResultExecutorTest.cs
  2882. @@ -210,12 +210,12 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  2883. public void FindView_WritesDiagnostic_ViewFound()
  2884. {
  2885. // Arrange
  2886. - var diagnosticSource = new DiagnosticListener("Test");
  2887. + var diagnosticListener = new DiagnosticListener("Test");
  2888. var listener = new TestDiagnosticListener();
  2889. - diagnosticSource.SubscribeWithAdapter(listener);
  2890. + diagnosticListener.SubscribeWithAdapter(listener);
  2891. var context = GetActionContext();
  2892. - var executor = GetViewExecutor(diagnosticSource);
  2893. + var executor = GetViewExecutor(diagnosticListener);
  2894. var viewName = "myview";
  2895. var viewResult = new PartialViewResult
  2896. @@ -243,12 +243,12 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  2897. public void FindView_WritesDiagnostic_ViewNotFound()
  2898. {
  2899. // Arrange
  2900. - var diagnosticSource = new DiagnosticListener("Test");
  2901. + var diagnosticListener = new DiagnosticListener("Test");
  2902. var listener = new TestDiagnosticListener();
  2903. - diagnosticSource.SubscribeWithAdapter(listener);
  2904. + diagnosticListener.SubscribeWithAdapter(listener);
  2905. var context = GetActionContext();
  2906. - var executor = GetViewExecutor(diagnosticSource);
  2907. + var executor = GetViewExecutor(diagnosticListener);
  2908. var viewName = "myview";
  2909. var viewEngine = new Mock<IViewEngine>(MockBehavior.Strict);
  2910. @@ -342,11 +342,11 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  2911. return new ActionContext(new DefaultHttpContext(), routeData, new ControllerActionDescriptor() { ActionName = actionName });
  2912. }
  2913. - private PartialViewResultExecutor GetViewExecutor(DiagnosticSource diagnosticSource = null)
  2914. + private PartialViewResultExecutor GetViewExecutor(DiagnosticListener diagnosticListener = null)
  2915. {
  2916. - if (diagnosticSource == null)
  2917. + if (diagnosticListener == null)
  2918. {
  2919. - diagnosticSource = new DiagnosticListener("Test");
  2920. + diagnosticListener = new DiagnosticListener("Test");
  2921. }
  2922. var viewEngine = new Mock<IViewEngine>(MockBehavior.Strict);
  2923. @@ -367,7 +367,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  2924. new TestHttpResponseStreamWriterFactory(),
  2925. new CompositeViewEngine(options),
  2926. new TempDataDictionaryFactory(new SessionStateTempDataProvider()),
  2927. - diagnosticSource,
  2928. + diagnosticListener,
  2929. NullLoggerFactory.Instance,
  2930. new EmptyModelMetadataProvider());
  2931. diff --git a/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewComponentResultTest.cs b/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewComponentResultTest.cs
  2932. index 5a94dc65464..4650edd55ed 100644
  2933. --- a/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewComponentResultTest.cs
  2934. +++ b/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewComponentResultTest.cs
  2935. @@ -560,7 +560,7 @@ namespace Microsoft.AspNetCore.Mvc
  2936. }
  2937. var services = new ServiceCollection();
  2938. - services.AddSingleton<DiagnosticSource>(diagnosticSource);
  2939. + services.AddSingleton<DiagnosticListener>(diagnosticSource);
  2940. services.AddSingleton<ViewComponentInvokerCache>();
  2941. services.AddSingleton<ExpressionTextCache>();
  2942. services.AddSingleton(Options.Create(new MvcViewOptions()));
  2943. diff --git a/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewComponents/ViewViewComponentResultTest.cs b/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewComponents/ViewViewComponentResultTest.cs
  2944. index 022c3d72bfd..989afc52ab9 100644
  2945. --- a/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewComponents/ViewViewComponentResultTest.cs
  2946. +++ b/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewComponents/ViewViewComponentResultTest.cs
  2947. @@ -355,7 +355,7 @@ namespace Microsoft.AspNetCore.Mvc
  2948. var serviceProvider = new Mock<IServiceProvider>();
  2949. serviceProvider.Setup(p => p.GetService(typeof(ICompositeViewEngine)))
  2950. .Returns(viewEngine.Object);
  2951. - serviceProvider.Setup(p => p.GetService(typeof(DiagnosticSource)))
  2952. + serviceProvider.Setup(p => p.GetService(typeof(DiagnosticListener)))
  2953. .Returns(new DiagnosticListener("Test"));
  2954. var viewData = new ViewDataDictionary(new EmptyModelMetadataProvider());
  2955. @@ -519,7 +519,7 @@ namespace Microsoft.AspNetCore.Mvc
  2956. diagnosticSource.SubscribeWithAdapter(diagnosticListener);
  2957. var serviceProvider = new Mock<IServiceProvider>();
  2958. - serviceProvider.Setup(s => s.GetService(typeof(DiagnosticSource))).Returns(diagnosticSource);
  2959. + serviceProvider.Setup(s => s.GetService(typeof(DiagnosticListener))).Returns(diagnosticSource);
  2960. var httpContext = new DefaultHttpContext();
  2961. httpContext.RequestServices = serviceProvider.Object;
  2962. diff --git a/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewExecutorTest.cs b/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewExecutorTest.cs
  2963. index 7fc8949fa34..2729b86e998 100644
  2964. --- a/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewExecutorTest.cs
  2965. +++ b/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewExecutorTest.cs
  2966. @@ -235,10 +235,10 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  2967. var adapter = new TestDiagnosticListener();
  2968. - var diagnosticSource = new DiagnosticListener("Test");
  2969. - diagnosticSource.SubscribeWithAdapter(adapter);
  2970. + var diagnosticListener = new DiagnosticListener("Test");
  2971. + diagnosticListener.SubscribeWithAdapter(adapter);
  2972. - var viewExecutor = CreateViewExecutor(diagnosticSource);
  2973. + var viewExecutor = CreateViewExecutor(diagnosticListener);
  2974. // Act
  2975. await viewExecutor.ExecuteAsync(
  2976. @@ -351,11 +351,11 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  2977. return view.Object;
  2978. }
  2979. - private ViewExecutor CreateViewExecutor(DiagnosticListener diagnosticSource = null)
  2980. + private ViewExecutor CreateViewExecutor(DiagnosticListener diagnosticListener = null)
  2981. {
  2982. - if (diagnosticSource == null)
  2983. + if (diagnosticListener == null)
  2984. {
  2985. - diagnosticSource = new DiagnosticListener("Test");
  2986. + diagnosticListener = new DiagnosticListener("Test");
  2987. }
  2988. return new ViewExecutor(
  2989. @@ -363,7 +363,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  2990. new TestHttpResponseStreamWriterFactory(),
  2991. new Mock<ICompositeViewEngine>(MockBehavior.Strict).Object,
  2992. new TempDataDictionaryFactory(new SessionStateTempDataProvider()),
  2993. - diagnosticSource,
  2994. + diagnosticListener,
  2995. new EmptyModelMetadataProvider());
  2996. }
  2997. }
  2998. diff --git a/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewResultExecutorTest.cs b/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewResultExecutorTest.cs
  2999. index f8a8ae87456..11d34a3d182 100644
  3000. --- a/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewResultExecutorTest.cs
  3001. +++ b/test/Microsoft.AspNetCore.Mvc.ViewFeatures.Test/ViewResultExecutorTest.cs
  3002. @@ -206,12 +206,12 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  3003. public void FindView_WritesDiagnostic_ViewFound()
  3004. {
  3005. // Arrange
  3006. - var diagnosticSource = new DiagnosticListener("Test");
  3007. + var diagnosticListener = new DiagnosticListener("Test");
  3008. var listener = new TestDiagnosticListener();
  3009. - diagnosticSource.SubscribeWithAdapter(listener);
  3010. + diagnosticListener.SubscribeWithAdapter(listener);
  3011. var context = GetActionContext();
  3012. - var executor = GetViewExecutor(diagnosticSource);
  3013. + var executor = GetViewExecutor(diagnosticListener);
  3014. var viewName = "myview";
  3015. var viewResult = new ViewResult
  3016. @@ -239,12 +239,12 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  3017. public void FindView_WritesDiagnostic_ViewNotFound()
  3018. {
  3019. // Arrange
  3020. - var diagnosticSource = new DiagnosticListener("Test");
  3021. + var diagnosticListener = new DiagnosticListener("Test");
  3022. var listener = new TestDiagnosticListener();
  3023. - diagnosticSource.SubscribeWithAdapter(listener);
  3024. + diagnosticListener.SubscribeWithAdapter(listener);
  3025. var context = GetActionContext();
  3026. - var executor = GetViewExecutor(diagnosticSource);
  3027. + var executor = GetViewExecutor(diagnosticListener);
  3028. var viewName = "myview";
  3029. var viewEngine = new Mock<IViewEngine>(MockBehavior.Strict);
  3030. @@ -332,11 +332,11 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  3031. return new ActionContext(new DefaultHttpContext(), routeData, new ControllerActionDescriptor() { ActionName = actionName });
  3032. }
  3033. - private ViewResultExecutor GetViewExecutor(DiagnosticListener diagnosticSource = null)
  3034. + private ViewResultExecutor GetViewExecutor(DiagnosticListener diagnosticListener = null)
  3035. {
  3036. - if (diagnosticSource == null)
  3037. + if (diagnosticListener == null)
  3038. {
  3039. - diagnosticSource = new DiagnosticListener("Test");
  3040. + diagnosticListener = new DiagnosticListener("Test");
  3041. }
  3042. var viewEngine = new Mock<IViewEngine>(MockBehavior.Strict);
  3043. @@ -357,7 +357,7 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures
  3044. new TestHttpResponseStreamWriterFactory(),
  3045. new CompositeViewEngine(options),
  3046. new TempDataDictionaryFactory(new SessionStateTempDataProvider()),
  3047. - diagnosticSource,
  3048. + diagnosticListener,
  3049. NullLoggerFactory.Instance,
  3050. new EmptyModelMetadataProvider());