// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.Razor.Compilation; using Microsoft.CodeAnalysis; using Microsoft.Extensions.FileProviders; namespace Microsoft.AspNetCore.Mvc.Razor { /// /// Provides programmatic configuration for the . /// public class RazorViewEngineOptions { private Action _compilationCallback = c => { }; /// /// Gets a used by the . /// public IList ViewLocationExpanders { get; } = new List(); /// /// Gets the sequence of instances used by to /// locate Razor files. /// /// /// At startup, this is initialized to include an instance of /// that is rooted at the application root. /// public IList FileProviders { get; } = new List(); /// /// Gets the locations where will search for views. /// /// /// /// The locations of the views returned from controllers that do not belong to an area. /// Locations are format strings (see https://msdn.microsoft.com/en-us/library/txafckwd.aspx) which may contain /// the following format items: /// /// /// /// {0} - Action Name /// /// /// {1} - Controller Name /// /// /// /// The values for these locations are case-sensitive on case-sensitive file systems. /// For example, the view for the Test action of HomeController should be located at /// /Views/Home/Test.cshtml. Locations such as /views/home/test.cshtml would not be discovered. /// /// public IList ViewLocationFormats { get; } = new List(); /// /// Gets the locations where will search for views within an /// area. /// /// /// /// The locations of the views returned from controllers that belong to an area. /// Locations are format strings (see https://msdn.microsoft.com/en-us/library/txafckwd.aspx) which may contain /// the following format items: /// /// /// /// {0} - Action Name /// /// /// {1} - Controller Name /// /// /// {2} - Area Name /// /// /// /// The values for these locations are case-sensitive on case-sensitive file systems. /// For example, the view for the Test action of HomeController under Admin area should /// be located at /Areas/Admin/Views/Home/Test.cshtml. /// Locations such as /areas/admin/views/home/test.cshtml would not be discovered. /// /// public IList AreaViewLocationFormats { get; } = new List(); /// /// Gets the locations where will search for views (such as layouts and partials) /// when searched from the context of rendering a Razor Page. /// /// /// /// Locations are format strings (see https://msdn.microsoft.com/en-us/library/txafckwd.aspx) which may contain /// the following format items: /// /// /// /// {0} - View Name /// /// /// {1} - Page Name /// /// /// /// work in tandem with a view location expander to perform hierarchical /// path lookups. For instance, given a Page like /Account/Manage/Index using /Pages as the root, the view engine /// will search for views in the following locations: /// /// /Pages/Account/Manage/{0}.cshtml /// /Pages/Account/{0}.cshtml /// /Pages/{0}.cshtml /// /Pages/Shared/{0}.cshtml /// /Views/Shared/{0}.cshtml /// /// public IList PageViewLocationFormats { get; } = new List(); /// /// Gets the locations where will search for views (such as layouts and partials) /// when searched from the context of rendering a Razor Page within an area. /// /// /// /// Locations are format strings (see https://msdn.microsoft.com/en-us/library/txafckwd.aspx) which may contain /// the following format items: /// /// /// /// {0} - View Name /// /// /// {1} - Page Name /// /// /// {2} - Area Name /// /// /// /// work in tandem with a view location expander to perform hierarchical /// path lookups. For instance, given a Page like /Areas/Account/Pages/Manage/User.cshtml using /Areas as the area pages root and /// /Pages as the root, the view engine will search for views in the following locations: /// /// /Areas/Accounts/Pages/Manage/{0}.cshtml /// /Areas/Accounts/Pages/{0}.cshtml /// /Areas/Accounts/Pages/Shared/{0}.cshtml /// /Areas/Accounts/Views/Shared/{0}.cshtml /// /Pages/Shared/{0}.cshtml /// /Views/Shared/{0}.cshtml /// /// public IList AreaPageViewLocationFormats { get; } = new List(); /// /// Gets the instances that should be included in Razor compilation, along with /// those discovered by s. /// [Obsolete("This property is obsolete and will be removed in a future version. See https://aka.ms/AA1x4gg for details.")] public IList AdditionalCompilationReferences { get; } = new List(); /// /// Gets or sets the callback that is used to customize Razor compilation /// to change compilation settings you can update property. /// /// /// Customizations made here would not reflect in tooling (Intellisense). /// [Obsolete("This property is obsolete and will be removed in a future version. See https://aka.ms/AA1x4gg for details.")] public Action CompilationCallback { get => _compilationCallback; set { if (value == null) { throw new ArgumentNullException(nameof(value)); } _compilationCallback = value; } } } }