From 2ef26486ddde046d3b7226c1f29290da6690c8fe Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 21 Jul 2017 12:32:28 -0700 Subject: [PATCH] Add global filters with the right scope Previously global filters were added to the page application model with Action scope. This would have resulted in incorrect ordering of filters during execution. We'll instead add global filters separately with the right scope. #6579 will be used to express global filters as part of the application model. --- .../CompiledPageActionDescriptorBuilder.cs | 10 ++-- .../DefaultPageApplicationModelProvider.cs | 15 ------ .../Internal/DefaultPageLoader.cs | 8 ++- ...izationPageApplicationModelProviderTest.cs | 2 +- ...CompiledPageActionDescriptorBuilderTest.cs | 52 +++++++++++++++++- ...DefaultPageApplicationModelProviderTest.cs | 54 ++++++++----------- .../Internal/DefaultPageLoaderTest.cs | 21 +++++--- 7 files changed, 101 insertions(+), 61 deletions(-) diff --git a/src/Microsoft.AspNetCore.Mvc.RazorPages/Internal/CompiledPageActionDescriptorBuilder.cs b/src/Microsoft.AspNetCore.Mvc.RazorPages/Internal/CompiledPageActionDescriptorBuilder.cs index c529c7bb4f..8fec2fd4a8 100644 --- a/src/Microsoft.AspNetCore.Mvc.RazorPages/Internal/CompiledPageActionDescriptorBuilder.cs +++ b/src/Microsoft.AspNetCore.Mvc.RazorPages/Internal/CompiledPageActionDescriptorBuilder.cs @@ -18,12 +18,16 @@ public static class CompiledPageActionDescriptorBuilder /// Creates a from the specified . /// /// The . + /// Global filters to apply to the page. /// The . - public static CompiledPageActionDescriptor Build(PageApplicationModel applicationModel) + public static CompiledPageActionDescriptor Build( + PageApplicationModel applicationModel, + FilterCollection globalFilters) { var boundProperties = CreateBoundProperties(applicationModel); - var filters = applicationModel.Filters - .Select(f => new FilterDescriptor(f, FilterScope.Action)) + var filters = Enumerable.Concat( + globalFilters.Select(f => new FilterDescriptor(f, FilterScope.Global)), + applicationModel.Filters.Select(f => new FilterDescriptor(f, FilterScope.Action))) .ToArray(); var handlerMethods = CreateHandlerMethods(applicationModel); diff --git a/src/Microsoft.AspNetCore.Mvc.RazorPages/Internal/DefaultPageApplicationModelProvider.cs b/src/Microsoft.AspNetCore.Mvc.RazorPages/Internal/DefaultPageApplicationModelProvider.cs index f253913c93..5e09d1519a 100644 --- a/src/Microsoft.AspNetCore.Mvc.RazorPages/Internal/DefaultPageApplicationModelProvider.cs +++ b/src/Microsoft.AspNetCore.Mvc.RazorPages/Internal/DefaultPageApplicationModelProvider.cs @@ -16,16 +16,6 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages.Internal public class DefaultPageApplicationModelProvider : IPageApplicationModelProvider { private const string ModelPropertyName = "Model"; - private readonly FilterCollection _globalFilters; - - /// - /// Initializes a new instance of . - /// - /// - public DefaultPageApplicationModelProvider(IOptions mvcOptions) - { - _globalFilters = mvcOptions.Value.Filters; - } /// public int Order => -1000; @@ -146,11 +136,6 @@ internal void PopulateHandlerMethods(PageApplicationModel pageModel) internal void PopulateFilters(PageApplicationModel pageModel) { - for (var i = 0; i < _globalFilters.Count; i++) - { - pageModel.Filters.Add(_globalFilters[i]); - } - for (var i = 0; i < pageModel.HandlerTypeAttributes.Count; i++) { if (pageModel.HandlerTypeAttributes[i] is IFilterMetadata filter) diff --git a/src/Microsoft.AspNetCore.Mvc.RazorPages/Internal/DefaultPageLoader.cs b/src/Microsoft.AspNetCore.Mvc.RazorPages/Internal/DefaultPageLoader.cs index 28ccd85e37..e31ed6d32b 100644 --- a/src/Microsoft.AspNetCore.Mvc.RazorPages/Internal/DefaultPageLoader.cs +++ b/src/Microsoft.AspNetCore.Mvc.RazorPages/Internal/DefaultPageLoader.cs @@ -6,6 +6,7 @@ using System.Linq; using System.Reflection; using Microsoft.AspNetCore.Mvc.ApplicationModels; +using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Razor.Compilation; using Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure; using Microsoft.Extensions.Options; @@ -17,11 +18,13 @@ public class DefaultPageLoader : IPageLoader private readonly IPageApplicationModelProvider[] _applicationModelProviders; private readonly IViewCompilerProvider _viewCompilerProvider; private readonly IPageApplicationModelConvention[] _conventions; + private readonly FilterCollection _globalFilters; public DefaultPageLoader( IEnumerable applicationModelProviders, IViewCompilerProvider viewCompilerProvider, - IOptions pageOptions) + IOptions pageOptions, + IOptions mvcOptions) { _applicationModelProviders = applicationModelProviders .OrderBy(p => p.Order) @@ -30,6 +33,7 @@ public DefaultPageLoader( _conventions = pageOptions.Value.Conventions .OfType() .ToArray(); + _globalFilters = mvcOptions.Value.Filters; } private IViewCompiler Compiler => _viewCompilerProvider.GetCompiler(); @@ -61,7 +65,7 @@ public CompiledPageActionDescriptor Load(PageActionDescriptor actionDescriptor) _conventions[i].Apply(context.PageApplicationModel); } - return CompiledPageActionDescriptorBuilder.Build(context.PageApplicationModel); + return CompiledPageActionDescriptorBuilder.Build(context.PageApplicationModel, _globalFilters); } } } \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Mvc.RazorPages.Test/Internal/AuthorizationPageApplicationModelProviderTest.cs b/test/Microsoft.AspNetCore.Mvc.RazorPages.Test/Internal/AuthorizationPageApplicationModelProviderTest.cs index 7da47e9589..feb20c2b98 100644 --- a/test/Microsoft.AspNetCore.Mvc.RazorPages.Test/Internal/AuthorizationPageApplicationModelProviderTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.RazorPages.Test/Internal/AuthorizationPageApplicationModelProviderTest.cs @@ -151,7 +151,7 @@ public void OnGet() { } private static PageApplicationModelProviderContext GetApplicationProviderContext(TypeInfo typeInfo) { - var defaultProvider = new DefaultPageApplicationModelProvider(new TestOptionsManager()); + var defaultProvider = new DefaultPageApplicationModelProvider(); var context = new PageApplicationModelProviderContext(new PageActionDescriptor(), typeInfo); defaultProvider.OnProvidersExecuting(context); return context; diff --git a/test/Microsoft.AspNetCore.Mvc.RazorPages.Test/Internal/CompiledPageActionDescriptorBuilderTest.cs b/test/Microsoft.AspNetCore.Mvc.RazorPages.Test/Internal/CompiledPageActionDescriptorBuilderTest.cs index ca13fb3f37..e6b45a8c84 100644 --- a/test/Microsoft.AspNetCore.Mvc.RazorPages.Test/Internal/CompiledPageActionDescriptorBuilderTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.RazorPages.Test/Internal/CompiledPageActionDescriptorBuilderTest.cs @@ -31,9 +31,10 @@ public void CreateDescriptor_CopiesPropertiesFromPageActionDescriptor() }; var handlerTypeInfo = typeof(object).GetTypeInfo(); var pageApplicationModel = new PageApplicationModel(actionDescriptor, handlerTypeInfo, new object[0]); + var globalFilters = new FilterCollection(); // Act - var actual = CompiledPageActionDescriptorBuilder.Build(pageApplicationModel); + var actual = CompiledPageActionDescriptorBuilder.Build(pageApplicationModel, globalFilters); // Assert Assert.Same(actionDescriptor.ActionConstraints, actual.ActionConstraints); @@ -78,9 +79,10 @@ public void CreateDescriptor_CopiesPropertiesFromPageApplicationModel() }, } }; + var globalFilters = new FilterCollection(); // Act - var actual = CompiledPageActionDescriptorBuilder.Build(pageApplicationModel); + var actual = CompiledPageActionDescriptorBuilder.Build(pageApplicationModel, globalFilters); // Assert Assert.Same(pageApplicationModel.PageType, actual.PageTypeInfo); @@ -92,6 +94,52 @@ public void CreateDescriptor_CopiesPropertiesFromPageApplicationModel() Assert.Equal(pageApplicationModel.HandlerProperties.Select(p => p.PropertyName), actual.BoundProperties.Select(p => p.Name)); } + [Fact] + public void CreateDescriptor_AddsGlobalFiltersWithTheRightScope() + { + // Arrange + var actionDescriptor = new PageActionDescriptor + { + ActionConstraints = new List(), + AttributeRouteInfo = new AttributeRouteInfo(), + FilterDescriptors = new List(), + RelativePath = "/Foo", + RouteValues = new Dictionary(), + ViewEnginePath = "/Pages/Foo", + }; + var handlerTypeInfo = typeof(TestModel).GetTypeInfo(); + var pageApplicationModel = new PageApplicationModel(actionDescriptor, handlerTypeInfo, new object[0]) + { + PageType = typeof(TestPage).GetTypeInfo(), + ModelType = typeof(TestModel).GetTypeInfo(), + Filters = + { + Mock.Of(), + }, + }; + var globalFilters = new FilterCollection + { + Mock.Of(), + }; + + // Act + var compiledPageActionDescriptor = CompiledPageActionDescriptorBuilder.Build(pageApplicationModel, globalFilters); + + // Assert + Assert.Collection( + compiledPageActionDescriptor.FilterDescriptors, + filterDescriptor => + { + Assert.Same(globalFilters[0], filterDescriptor.Filter); + Assert.Equal(FilterScope.Global, filterDescriptor.Scope); + }, + filterDescriptor => + { + Assert.Same(pageApplicationModel.Filters[0], filterDescriptor.Filter); + Assert.Equal(FilterScope.Action, filterDescriptor.Scope); + }); + } + private class TestPage { public TestModel Model { get; } = new TestModel(); diff --git a/test/Microsoft.AspNetCore.Mvc.RazorPages.Test/Internal/DefaultPageApplicationModelProviderTest.cs b/test/Microsoft.AspNetCore.Mvc.RazorPages.Test/Internal/DefaultPageApplicationModelProviderTest.cs index ca4e47583b..fca35d2c75 100644 --- a/test/Microsoft.AspNetCore.Mvc.RazorPages.Test/Internal/DefaultPageApplicationModelProviderTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.RazorPages.Test/Internal/DefaultPageApplicationModelProviderTest.cs @@ -21,7 +21,7 @@ public class DefaultPageApplicationModelProviderTest public void OnProvidersExecuting_ThrowsIfPageDoesNotDeriveFromValidBaseType() { // Arrange - var provider = new TestPageApplicationModelProvider(); + var provider = new DefaultPageApplicationModelProvider(); var typeInfo = typeof(InvalidPageWithWrongBaseClass).GetTypeInfo(); var descriptor = new PageActionDescriptor(); var context = new PageApplicationModelProviderContext(descriptor, typeInfo); @@ -62,7 +62,7 @@ public override Task ExecuteAsync() public void OnProvidersExecuting_ThrowsIfModelPropertyDoesNotExistOnPage() { // Arrange - var provider = new TestPageApplicationModelProvider(); + var provider = new DefaultPageApplicationModelProvider(); var typeInfo = typeof(PageWithoutModelProperty).GetTypeInfo(); var descriptor = new PageActionDescriptor(); var context = new PageApplicationModelProviderContext(descriptor, typeInfo); @@ -85,7 +85,7 @@ private class PageWithoutModelProperty : PageBase public void OnProvidersExecuting_ThrowsIfModelPropertyIsNotPublic() { // Arrange - var provider = new TestPageApplicationModelProvider(); + var provider = new DefaultPageApplicationModelProvider(); var typeInfo = typeof(PageWithNonVisibleModel).GetTypeInfo(); var descriptor = new PageActionDescriptor(); var context = new PageApplicationModelProviderContext(descriptor, typeInfo); @@ -110,7 +110,7 @@ private class PageWithNonVisibleModel : PageBase public void OnProvidersExecuting_ThrowsIfModelPropertyIsStatic() { // Arrange - var provider = new TestPageApplicationModelProvider(); + var provider = new DefaultPageApplicationModelProvider(); var typeInfo = typeof(PageWithStaticModel).GetTypeInfo(); var descriptor = new PageActionDescriptor(); var context = new PageApplicationModelProviderContext(descriptor, typeInfo); @@ -135,7 +135,7 @@ private class PageWithStaticModel : PageBase public void OnProvidersExecuting_DiscoversPropertiesFromPage_IfModelTypeDoesNotHaveAttribute() { // Arrange - var provider = new TestPageApplicationModelProvider(); + var provider = new DefaultPageApplicationModelProvider(); var typeInfo = typeof(PageWithModelWithoutPageModelAttribute).GetTypeInfo(); var descriptor = new PageActionDescriptor(); var context = new PageApplicationModelProviderContext(descriptor, typeInfo); @@ -189,7 +189,7 @@ private class ModelWithoutPageModelAttribute public void OnProvidersExecuting_DiscoversPropertiesFromPageModel_IfModelHasAttribute() { // Arrange - var provider = new TestPageApplicationModelProvider(); + var provider = new DefaultPageApplicationModelProvider(); var typeInfo = typeof(PageWithModelWithPageModelAttribute).GetTypeInfo(); var modelType = typeof(ModelWithPageModelAttribute); var descriptor = new PageActionDescriptor(); @@ -233,7 +233,7 @@ private class ModelWithPageModelAttribute public void OnProvidersExecuting_DiscoversHandlersFromPage() { // Arrange - var provider = new TestPageApplicationModelProvider(); + var provider = new DefaultPageApplicationModelProvider(); var typeInfo = typeof(PageWithModelWithoutHandlers).GetTypeInfo(); var descriptor = new PageActionDescriptor(); var context = new PageApplicationModelProviderContext(descriptor, typeInfo); @@ -275,7 +275,7 @@ public void OnProvidersExecuting_DiscoversHandlersFromPage() public void OnProvidersExecuting_DiscoversPropertiesFromModel() { // Arrange - var provider = new TestPageApplicationModelProvider(); + var provider = new DefaultPageApplicationModelProvider(); var typeInfo = typeof(PageWithModel).GetTypeInfo(); var modelType = typeof(TestPageModel); var descriptor = new PageActionDescriptor(); @@ -309,7 +309,7 @@ public void OnProvidersExecuting_DiscoversPropertiesFromModel() public void OnProvidersExecuting_DiscoversHandlersFromModel() { // Arrange - var provider = new TestPageApplicationModelProvider(); + var provider = new DefaultPageApplicationModelProvider(); var typeInfo = typeof(PageWithModel).GetTypeInfo(); var modelType = typeof(TestPageModel); var descriptor = new PageActionDescriptor(); @@ -337,7 +337,7 @@ public void OnProvidersExecuting_DiscoversHandlersFromModel() public void OnProvidersExecuting_EmptyPage() { // Arrange - var provider = new TestPageApplicationModelProvider(); + var provider = new DefaultPageApplicationModelProvider(); var typeInfo = typeof(EmptyPage).GetTypeInfo(); var context = new PageApplicationModelProviderContext(new PageActionDescriptor(), typeInfo); @@ -358,7 +358,7 @@ public void OnProvidersExecuting_EmptyPage() public void OnProvidersExecuting_EmptyPageModel() { // Arrange - var provider = new TestPageApplicationModelProvider(); + var provider = new DefaultPageApplicationModelProvider(); var typeInfo = typeof(EmptyPageWithPageModel).GetTypeInfo(); var context = new PageApplicationModelProviderContext(new PageActionDescriptor(), typeInfo); @@ -426,7 +426,7 @@ private class EmptyPageModel : PageModel public void CreateDescriptor_FindsHandlerMethod_OnModel() { // Arrange - var provider = new TestPageApplicationModelProvider(); + var provider = new DefaultPageApplicationModelProvider(); var typeInfo = typeof(PageWithHandlerThatGetsIgnored).GetTypeInfo(); var modelType = typeof(ModelWithHandler); var context = new PageApplicationModelProviderContext(new PageActionDescriptor(), typeInfo); @@ -473,7 +473,7 @@ public void OnPost() { } public void OnProvidersExecuting_FindsHandlerMethodOnPage_WhenModelIsNotAnnotatedWithPageModelAttribute() { // Arrange - var provider = new TestPageApplicationModelProvider(); + var provider = new DefaultPageApplicationModelProvider(); var typeInfo = typeof(PageWithHandler).GetTypeInfo(); var context = new PageApplicationModelProviderContext(new PageActionDescriptor(), typeInfo); @@ -524,7 +524,7 @@ public void OnGet() { } public void PopulateHandlerMethods_DiscoversHandlersFromBaseType() { // Arrange - var provider = new TestPageApplicationModelProvider(); + var provider = new DefaultPageApplicationModelProvider(); var typeInfo = typeof(InheritsMethods).GetTypeInfo(); var baseType = typeof(TestSetPageModel); var pageModel = new PageApplicationModel(new PageActionDescriptor(), typeInfo, new object[0]); @@ -575,7 +575,7 @@ private class InheritsMethods : TestSetPageModel public void PopulateHandlerMethods_IgnoresNonPublicMethods() { // Arrange - var provider = new TestPageApplicationModelProvider(); + var provider = new DefaultPageApplicationModelProvider(); var typeInfo = typeof(ProtectedModel).GetTypeInfo(); var baseType = typeof(TestSetPageModel); var pageModel = new PageApplicationModel(new PageActionDescriptor(), typeInfo, new object[0]); @@ -603,7 +603,7 @@ private void OnPost() public void PopulateHandlerMethods_IgnoreGenericTypeParameters() { // Arrange - var provider = new TestPageApplicationModelProvider(); + var provider = new DefaultPageApplicationModelProvider(); var typeInfo = typeof(GenericClassModel).GetTypeInfo(); var pageModel = new PageApplicationModel(new PageActionDescriptor(), typeInfo, new object[0]); @@ -626,7 +626,7 @@ public void OnGet() public void PopulateHandlerMethods_IgnoresStaticMethods() { // Arrange - var provider = new TestPageApplicationModelProvider(); + var provider = new DefaultPageApplicationModelProvider(); var typeInfo = typeof(PageModelWithStaticHandler).GetTypeInfo(); var expected = typeInfo.GetMethod(nameof(PageModelWithStaticHandler.OnGet), BindingFlags.Public | BindingFlags.Instance); var pageModel = new PageApplicationModel(new PageActionDescriptor(), typeInfo, new object[0]); @@ -656,7 +656,7 @@ public void OnGet() public void PopulateHandlerMethods_IgnoresAbstractMethods() { // Arrange - var provider = new TestPageApplicationModelProvider(); + var provider = new DefaultPageApplicationModelProvider(); var typeInfo = typeof(PageModelWithAbstractMethod).GetTypeInfo(); var expected = typeInfo.GetMethod(nameof(PageModelWithAbstractMethod.OnGet), BindingFlags.Public | BindingFlags.Instance); var pageModel = new PageApplicationModel(new PageActionDescriptor(), typeInfo, new object[0]); @@ -684,7 +684,7 @@ public void OnGet() public void PopulateHandlerMethods_IgnoresMethodWithNonHandlerAttribute() { // Arrange - var provider = new TestPageApplicationModelProvider(); + var provider = new DefaultPageApplicationModelProvider(); var typeInfo = typeof(PageWithNonHandlerMethod).GetTypeInfo(); var expected = typeInfo.GetMethod(nameof(PageWithNonHandlerMethod.OnGet), BindingFlags.Public | BindingFlags.Instance); var pageModel = new PageApplicationModel(new PageActionDescriptor(), typeInfo, new object[0]); @@ -715,7 +715,7 @@ public void OnGet() public void CreateHandlerModel_ParsesMethod() { // Arrange - var provider = new TestPageApplicationModelProvider(); + var provider = new DefaultPageApplicationModelProvider(); var typeInfo = typeof(PageModelWithHandlerNames).GetTypeInfo(); var pageModel = new PageApplicationModel(new PageActionDescriptor(), typeInfo, new object[0]); @@ -749,7 +749,7 @@ public void Foo() // This isn't a valid handler name. public void CreateHandlerMethods_AddsParameterDescriptors() { // Arrange - var provider = new TestPageApplicationModelProvider(); + var provider = new DefaultPageApplicationModelProvider(); var typeInfo = typeof(PageWithHandlerParameters).GetTypeInfo(); var expected = typeInfo.GetMethod(nameof(PageWithHandlerParameters.OnPost)); var pageModel = new PageApplicationModel(new PageActionDescriptor(), typeInfo, new object[0]); @@ -793,7 +793,7 @@ public void OnPost(string name, [ModelBinder(Name = "personId")] int id) { } public void PopulateHandlerProperties_UsesPropertyHelpers_ToFindProperties() { // Arrange - var provider = new TestPageApplicationModelProvider(); + var provider = new DefaultPageApplicationModelProvider(); var typeInfo = typeof(HidesAProperty).GetTypeInfo(); var pageModel = new PageApplicationModel(new PageActionDescriptor(), typeInfo, new object[0]); @@ -826,7 +826,7 @@ private class HidesAProperty : HasAHiddenProperty public void PopulateHandlerProperties_SupportsGet_OnProperty() { // Arrange - var provider = new TestPageApplicationModelProvider(); + var provider = new DefaultPageApplicationModelProvider(); var typeInfo = typeof(ModelSupportsGetOnProperty).GetTypeInfo(); var pageModel = new PageApplicationModel(new PageActionDescriptor(), typeInfo, new object[0]); @@ -898,14 +898,6 @@ public void TryParseHandler_ParsesHandlerNames_ValidData(string methodName, stri Assert.Equal(expectedHandler, handler); } - private class TestPageApplicationModelProvider : DefaultPageApplicationModelProvider - { - public TestPageApplicationModelProvider(IOptions mvcOptions = null) - : base(mvcOptions : new TestOptionsManager()) - { - } - } - private class PageWithModelWithoutHandlers : Page { public ModelWithoutHandler Model { get; } diff --git a/test/Microsoft.AspNetCore.Mvc.RazorPages.Test/Internal/DefaultPageLoaderTest.cs b/test/Microsoft.AspNetCore.Mvc.RazorPages.Test/Internal/DefaultPageLoaderTest.cs index 2530d1e003..d9a2639e6b 100644 --- a/test/Microsoft.AspNetCore.Mvc.RazorPages.Test/Internal/DefaultPageLoaderTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.RazorPages.Test/Internal/DefaultPageLoaderTest.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Reflection; +using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.ApplicationModels; using Microsoft.AspNetCore.Mvc.Razor.Compilation; using Microsoft.AspNetCore.Mvc.RazorPages.Infrastructure; @@ -20,7 +21,8 @@ public void Load_InvokesApplicationModelProviders() var compilerProvider = GetCompilerProvider(); - var options = new TestOptionsManager(); + var razorPagesOptions = new TestOptionsManager(); + var mvcOptions = new TestOptionsManager(); var provider1 = new Mock(); var provider2 = new Mock(); @@ -71,7 +73,8 @@ public void Load_InvokesApplicationModelProviders() var loader = new DefaultPageLoader( providers, compilerProvider, - options); + razorPagesOptions, + mvcOptions); // Act var result = loader.Load(new PageActionDescriptor()); @@ -87,7 +90,8 @@ public void Load_InvokesApplicationModelProviders_WithTheRightOrder() // Arrange var descriptor = new PageActionDescriptor(); var compilerProvider = GetCompilerProvider(); - var options = new TestOptionsManager(); + var razorPagesOptions = new TestOptionsManager(); + var mvcOptions = new TestOptionsManager(); var provider1 = new Mock(); provider1.SetupGet(p => p.Order).Returns(10); @@ -132,7 +136,8 @@ public void Load_InvokesApplicationModelProviders_WithTheRightOrder() var loader = new DefaultPageLoader( providers, compilerProvider, - options); + razorPagesOptions, + mvcOptions); // Act var result = loader.Load(new PageActionDescriptor()); @@ -159,19 +164,21 @@ public void Load_InvokesApplicationModelConventions() }); var providers = new[] { provider.Object }; - var options = new TestOptionsManager(); + var razorPagesOptions = new TestOptionsManager(); + var mvcOptions = new TestOptionsManager(); var convention = new Mock(); convention.Setup(c => c.Apply(It.IsAny())) .Callback((PageApplicationModel m) => { Assert.Same(model, m); }); - options.Value.Conventions.Add(convention.Object); + razorPagesOptions.Value.Conventions.Add(convention.Object); var loader = new DefaultPageLoader( providers, compilerProvider, - options); + razorPagesOptions, + mvcOptions); // Act var result = loader.Load(new PageActionDescriptor());