From 929d7f3306cb7aeeaba5a996b65c5371deef8b30 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Thu, 29 Nov 2018 15:07:19 -0800 Subject: [PATCH] Obsolete old `CompatibilityVersion` values - #7156 part 1 of ? - add `CompatibilityVersion.Version_3_0` and make it the default - remove tests of old versions - also remove `CompatibilityVersion.Version_2_x` uses outside src/Mvc - for functional tests of legacy routing, use `MvcOptions.EnableEndpointRouting` to control behaviour - rename `StartupWith2xCompat...` classes to `StartupWithoutEndpointRouting` - clean up comments mentioning `[Obsolete]` `CompatibilityVersion` values - many of the affected options will be removed in subsequent PRs but this cleanup helps when searching entire repo - correct `` comments in `ApiBehaviorOptions` nits: - take VS suggestions in changed files - remove src/SiteExtensions/global.json and let file in repo root "win" - fix a few grammar errors VS or the spell checker noticed - move `` elements before `` for consistency - was undoing unintentional changes and noticed the inconsistency in a couple of additional files --- .../samples/StaticFilesAuth/Startup.cs | 7 +- .../ModelBinding/ModelMetadata.cs | 2 +- .../ApiBehaviorOptions.cs | 75 +------- .../CompatibilityVersion.cs | 19 +- .../ApiBehaviorOptionsSetup.cs | 11 +- .../Infrastructure/MvcCompatibilityOptions.cs | 3 +- ...MvcOptionsConfigureCompatibilityOptions.cs | 29 +-- .../MvcOptions.cs | 182 ++---------------- ...calizationConfigureCompatibilityOptions.cs | 11 +- .../MvcDataAnnotationsLocalizationOptions.cs | 25 +-- ...sonOptionsConfigureCompatibilityOptions.cs | 12 +- .../MvcJsonOptions.cs | 30 +-- ...XmlOptionsConfigureCompatibilityOptions.cs | 13 +- .../MvcXmlOptions.cs | 22 +-- .../RazorPagesOptions.cs | 72 +------ ...gesOptionsConfigureCompatibilityOptions.cs | 20 +- .../MvcViewOptions.cs | 34 +--- ...iewOptionsConfigureCompatibilityOptions.cs | 16 +- .../TemplateInfo.cs | 4 +- .../ApiBehaviorOptionsSetupTest.cs | 17 -- .../ConfigureCompatibilityOptionsTest.cs | 26 +-- ...ptionsConfigureCompatibilityOptionsTest.cs | 6 +- .../CorsEndpointRoutingTests.cs | 4 +- .../CorsTests.cs | 6 +- .../CorsTestsBase.cs | 2 +- .../GlobalAuthorizationFilterTest.cs | 29 +-- .../HtmlGenerationTest.cs | 2 +- .../RoutingTests.cs | 4 +- .../VersioningEndpointRoutingTests.cs | 2 +- .../VersioningTests.cs | 6 +- .../VersioningTestsBase.cs | 2 +- ...ontractSerializerFormattersWrappingTest.cs | 57 +----- .../XmlSerializerFormattersWrappingTest.cs | 57 +----- .../ModelBindingTestHelper.cs | 4 +- .../CompatibilitySwitchIntegrationTest.cs | 80 +------- src/Mvc/test/WebSites/CorsWebSite/Startup.cs | 6 +- .../CorsWebSite/StartupWith21Compat.cs | 80 -------- .../StartupWithoutEndpointRouting.cs | 15 ++ .../WebSites/HtmlGenerationWebSite/Startup.cs | 6 +- .../StartupWith21CompatibilityBehavior.cs | 55 ------ .../StartupWithoutEndpointRouting.cs | 15 ++ .../test/WebSites/RoutingWebSite/Startup.cs | 60 +++--- .../RoutingWebSite/StartupWith21Compat.cs | 99 ---------- .../StartupWithoutEndpointRouting.cs | 49 +++++ ...ith20CompatAndGlobalDenyAnonymousFilter.cs | 41 ---- .../WebSites/VersioningWebSite/Startup.cs | 8 +- .../VersioningWebSite/StartupWith21Compat.cs | 28 --- .../StartupWithoutEndpointRouting.cs | 15 ++ .../StartupWith21Compat.cs | 13 -- src/SiteExtensions/global.json | 8 - .../content/RazorPagesWeb-CSharp/Startup.cs | 5 +- .../content/StarterWeb-CSharp/Startup.cs | 7 +- .../content/StarterWeb-FSharp/Startup.fs | 4 +- .../content/WebApi-CSharp/Startup.cs | 4 +- .../content/WebApi-FSharp/Startup.fs | 2 +- .../content/Angular-CSharp/Startup.cs | 2 +- .../content/React-CSharp/Startup.cs | 2 +- .../content/ReactRedux-CSharp/Startup.cs | 2 +- 58 files changed, 318 insertions(+), 1099 deletions(-) delete mode 100644 src/Mvc/test/WebSites/CorsWebSite/StartupWith21Compat.cs create mode 100644 src/Mvc/test/WebSites/CorsWebSite/StartupWithoutEndpointRouting.cs delete mode 100644 src/Mvc/test/WebSites/HtmlGenerationWebSite/StartupWith21CompatibilityBehavior.cs create mode 100644 src/Mvc/test/WebSites/HtmlGenerationWebSite/StartupWithoutEndpointRouting.cs delete mode 100644 src/Mvc/test/WebSites/RoutingWebSite/StartupWith21Compat.cs create mode 100644 src/Mvc/test/WebSites/RoutingWebSite/StartupWithoutEndpointRouting.cs delete mode 100644 src/Mvc/test/WebSites/SecurityWebSite/StartupWith20CompatAndGlobalDenyAnonymousFilter.cs delete mode 100644 src/Mvc/test/WebSites/VersioningWebSite/StartupWith21Compat.cs create mode 100644 src/Mvc/test/WebSites/VersioningWebSite/StartupWithoutEndpointRouting.cs delete mode 100644 src/Mvc/test/WebSites/XmlFormattersWebSite/StartupWith21Compat.cs delete mode 100644 src/SiteExtensions/global.json diff --git a/src/AuthSamples/samples/StaticFilesAuth/Startup.cs b/src/AuthSamples/samples/StaticFilesAuth/Startup.cs index 91fef94b9e..88cc442b6e 100644 --- a/src/AuthSamples/samples/StaticFilesAuth/Startup.cs +++ b/src/AuthSamples/samples/StaticFilesAuth/Startup.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using System.IO; using System.Linq; using Microsoft.AspNetCore.Authentication.Cookies; @@ -7,8 +6,6 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Http.Endpoints; -using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.FileProviders; @@ -71,7 +68,7 @@ namespace StaticFilesAuth }); }); - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + services.AddMvc(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. @@ -90,7 +87,7 @@ namespace StaticFilesAuth app.UseStaticFiles(); app.UseAuthentication(); - + var files = new PhysicalFileProvider(Path.Combine(env.ContentRootPath, "PrivateFiles")); app.Map("/MapAuthenticatedFiles", branch => diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Abstractions/ModelBinding/ModelMetadata.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Abstractions/ModelBinding/ModelMetadata.cs index 05f5f4cdfe..f16a9d481a 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Abstractions/ModelBinding/ModelMetadata.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Abstractions/ModelBinding/ModelMetadata.cs @@ -270,11 +270,11 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding /// Gets a value indicating where the current metadata should be ordered relative to other properties /// in its containing type. /// + /// The order value of the current metadata. /// /// For example this property is used to order items in . /// The default order is 10000. /// - /// The order value of the current metadata. public abstract int Order { get; } /// diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/ApiBehaviorOptions.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/ApiBehaviorOptions.cs index 26a796130c..8199849002 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/ApiBehaviorOptions.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/ApiBehaviorOptions.cs @@ -75,40 +75,23 @@ namespace Microsoft.AspNetCore.Mvc /// /// Gets or sets a value that determines if controllers with - /// transform certain certain client errors. + /// transform certain client errors. + /// + /// When , a result filter is added to API controller actions that transforms + /// . Otherwise, the filter is suppressed. + /// /// - /// When false, a result filter is added to API controller actions that transforms . /// By default, is used to map to a /// instance (returned as the value for ). /// /// /// To customize the output of the filter (for e.g. to return a different error type), register a custom - /// implementation of of in the service collection. + /// implementation of in the service collection. /// /// /// - /// The default value is if the version is - /// or later; otherwise. + /// The default value is . /// - /// - /// - /// This property is associated with a compatibility switch and can provide a different behavior depending on - /// the configured compatibility version for the application. See for - /// guidance and examples of setting the application's compatibility version. - /// - /// - /// Configuring the desired value of the compatibility switch by calling this property's setter will take - /// precedence over the value implied by the application's . - /// - /// - /// If the application's compatibility version is set to or - /// lower then this setting will have the value unless explicitly configured. - /// - /// - /// If the application's compatibility version is set to or - /// higher then this setting will have the value unless explicitly configured. - /// - /// public bool SuppressMapClientErrors { // Note: When compatibility switches are removed in 3.0, this property should be retained as a regular boolean property. @@ -126,28 +109,8 @@ namespace Microsoft.AspNetCore.Mvc /// /// /// - /// The default value is if the version is - /// or later; otherwise. + /// The default value is . /// - /// - /// - /// This property is associated with a compatibility switch and can provide a different behavior depending on - /// the configured compatibility version for the application. See for - /// guidance and examples of setting the application's compatibility version. - /// - /// - /// Configuring the desired value of the compatibility switch by calling this property's setter will take - /// precedence over the value implied by the application's . - /// - /// - /// If the application's compatibility version is set to or - /// lower then this setting will have the value unless explicitly configured. - /// - /// - /// If the application's compatibility version is set to or - /// higher then this setting will have the value unless explicitly configured. - /// - /// public bool SuppressUseValidationProblemDetailsForInvalidModelStateResponses { get => _suppressUseValidationProblemDetailsForInvalidModelStateResponses.Value; @@ -163,28 +126,8 @@ namespace Microsoft.AspNetCore.Mvc /// /// /// - /// The default value is if the version is - /// or later; otherwise. + /// The default value is . /// - /// - /// - /// This property is associated with a compatibility switch and can provide a different behavior depending on - /// the configured compatibility version for the application. See for - /// guidance and examples of setting the application's compatibility version. - /// - /// - /// Configuring the desired value of the compatibility switch by calling this property's setter takes - /// precedence over the value implied by the application's . - /// - /// - /// If the application's compatibility version is set to or - /// lower then this setting will have the value unless explicitly configured. - /// - /// - /// If the application's compatibility version is set to or - /// higher then this setting will have the value unless explicitly configured. - /// - /// public bool AllowInferringBindingSourceForCollectionTypesAsFromQuery { get => _allowInferringBindingSourceForCollectionTypesAsFromQuery.Value; diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/CompatibilityVersion.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/CompatibilityVersion.cs index d35cdd6110..fbd921e770 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/CompatibilityVersion.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/CompatibilityVersion.cs @@ -1,6 +1,7 @@ // 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 Microsoft.Extensions.DependencyInjection; namespace Microsoft.AspNetCore.Mvc @@ -23,7 +24,7 @@ namespace Microsoft.AspNetCore.Mvc /// /// public void ConfigureServices(IServiceCollection services) /// { - /// services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + /// services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_3_0); /// } /// /// ... @@ -42,6 +43,8 @@ namespace Microsoft.AspNetCore.Mvc /// Sets the default value of settings on to match the behavior of /// ASP.NET Core MVC 2.0. /// + [Obsolete("This " + nameof(CompatibilityVersion) + " value is obsolete. The recommended alternatives are " + + nameof(Version_3_0) + " or later.")] Version_2_0, /// @@ -49,7 +52,7 @@ namespace Microsoft.AspNetCore.Mvc /// ASP.NET Core MVC 2.1. /// /// - /// ASP.NET Core MVC 2.1 introduces compatibility switches for the following: + /// ASP.NET Core MVC 2.1 introduced compatibility switches for the following: /// /// /// @@ -60,6 +63,8 @@ namespace Microsoft.AspNetCore.Mvc /// RazorPagesOptions.AllowMappingHeadRequestsToGetHandler /// /// + [Obsolete("This " + nameof(CompatibilityVersion) + " value is obsolete. The recommended alternatives are " + + nameof(Version_3_0) + " or later.")] Version_2_1, /// @@ -67,7 +72,7 @@ namespace Microsoft.AspNetCore.Mvc /// ASP.NET Core MVC 2.2. /// /// - /// ASP.NET Core MVC 2.2 introduces compatibility switches for the following: + /// ASP.NET Core MVC 2.2 introduced compatibility switches for the following: /// /// ApiBehaviorOptions.SuppressMapClientErrors /// ApiBehaviorOptions.SuppressUseValidationProblemDetailsForInvalidModelStateResponses @@ -81,8 +86,16 @@ namespace Microsoft.AspNetCore.Mvc /// MvcXmlOptions.AllowRfc7807CompliantProblemDetailsFormat /// /// + [Obsolete("This " + nameof(CompatibilityVersion) + " value is obsolete. The recommended alternatives are " + + nameof(Version_3_0) + " or later.")] Version_2_2, + /// + /// Sets the default value of settings on and other Options types to match + /// the behavior of ASP.NET Core MVC 3.0. + /// + Version_3_0, + /// /// Sets the default value of settings on to match the latest release. Use this /// value with care, upgrading minor versions will cause breaking changes when using . diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/DependencyInjection/ApiBehaviorOptionsSetup.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/DependencyInjection/ApiBehaviorOptionsSetup.cs index 6203729684..d29e5c5872 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/DependencyInjection/ApiBehaviorOptionsSetup.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/DependencyInjection/ApiBehaviorOptionsSetup.cs @@ -30,16 +30,7 @@ namespace Microsoft.Extensions.DependencyInjection { get { - var dictionary = new Dictionary(); - - if (Version < CompatibilityVersion.Version_2_2) - { - dictionary[nameof(ApiBehaviorOptions.SuppressMapClientErrors)] = true; - dictionary[nameof(ApiBehaviorOptions.SuppressUseValidationProblemDetailsForInvalidModelStateResponses)] = true; - dictionary[nameof(ApiBehaviorOptions.AllowInferringBindingSourceForCollectionTypesAsFromQuery)] = true; - } - - return dictionary; + return new Dictionary(); } } diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/Infrastructure/MvcCompatibilityOptions.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/Infrastructure/MvcCompatibilityOptions.cs index fb78662ed8..624bf294c8 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/Infrastructure/MvcCompatibilityOptions.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/Infrastructure/MvcCompatibilityOptions.cs @@ -18,6 +18,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure /// /// Gets or sets the application's configured . /// - public CompatibilityVersion CompatibilityVersion { get; set; } = CompatibilityVersion.Version_2_0; + /// the default value is . + public CompatibilityVersion CompatibilityVersion { get; set; } = CompatibilityVersion.Version_3_0; } } diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/Infrastructure/MvcOptionsConfigureCompatibilityOptions.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/Infrastructure/MvcOptionsConfigureCompatibilityOptions.cs index 850d24e385..b0f809c14c 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/Infrastructure/MvcOptionsConfigureCompatibilityOptions.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/Infrastructure/MvcOptionsConfigureCompatibilityOptions.cs @@ -21,29 +21,20 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure { get { - var values = new Dictionary(); - - if (Version >= CompatibilityVersion.Version_2_1) + return new Dictionary { - values[nameof(MvcOptions.AllowCombiningAuthorizeFilters)] = true; - values[nameof(MvcOptions.AllowBindingHeaderValuesToNonStringModelTypes)] = true; - values[nameof(MvcOptions.AllowValidatingTopLevelNodes)] = true; - values[nameof(MvcOptions.InputFormatterExceptionPolicy)] = InputFormatterExceptionPolicy.MalformedInputExceptions; - values[nameof(MvcOptions.SuppressBindingUndefinedValueToEnumType)] = true; - } - - if (Version >= CompatibilityVersion.Version_2_2) - { - values[nameof(MvcOptions.EnableEndpointRouting)] = true; + [nameof(MvcOptions.AllowCombiningAuthorizeFilters)] = true, + [nameof(MvcOptions.AllowBindingHeaderValuesToNonStringModelTypes)] = true, + [nameof(MvcOptions.AllowValidatingTopLevelNodes)] = true, + [nameof(MvcOptions.InputFormatterExceptionPolicy)] = InputFormatterExceptionPolicy.MalformedInputExceptions, + [nameof(MvcOptions.SuppressBindingUndefinedValueToEnumType)] = true, + [nameof(MvcOptions.EnableEndpointRouting)] = true, // Matches JsonSerializerSettingsProvider.DefaultMaxDepth - values[nameof(MvcOptions.MaxValidationDepth)] = 32; + [nameof(MvcOptions.MaxValidationDepth)] = 32, - values[nameof(MvcOptions.AllowShortCircuitingValidationWhenNoValidatorsArePresent)] = true; - - } - - return values; + [nameof(MvcOptions.AllowShortCircuitingValidationWhenNoValidatorsArePresent)] = true, + }; } } } diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/MvcOptions.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/MvcOptions.cs index a97c9a965e..3bc6332eb3 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/MvcOptions.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/MvcOptions.cs @@ -80,28 +80,8 @@ namespace Microsoft.AspNetCore.Mvc /// URLs with . /// /// - /// The default value is if the version is - /// or later; otherwise. + /// The default value is . /// - /// - /// - /// This property is associated with a compatibility switch and can provide a different behavior depending on - /// the configured compatibility version for the application. See for - /// guidance and examples of setting the application's compatibility version. - /// - /// - /// Configuring the desired value of the compatibility switch by calling this property's setter will take - /// precedence over the value implied by the application's . - /// - /// - /// If the application's compatibility version is set to or - /// lower then this setting will have the value unless explicitly configured. - /// - /// - /// If the application's compatibility version is set to or - /// higher then this setting will have the value unless explicitly configured. - /// - /// public bool EnableEndpointRouting { get => _enableEndpointRouting.Value; @@ -122,10 +102,12 @@ namespace Microsoft.AspNetCore.Mvc /// /// Gets or sets a value that determines if policies on instances of - /// will be combined into a single effective policy. The default value of the property is false. + /// will be combined into a single effective policy. /// + /// + /// The default value is . + /// /// - /// /// Authorization policies are designed such that multiple authorization policies applied to an endpoint /// should be combined and executed a single policy. The (commonly applied /// by ) can be applied globally, to controllers, and to actions - which @@ -133,24 +115,6 @@ namespace Microsoft.AspNetCore.Mvc /// these multiple policies would not combine as intended. This compatibility switch configures whether the /// old (unintended) behavior or the new combining behavior will be used when multiple authorization policies /// are applied. - /// - /// - /// This property is associated with a compatibility switch and can provide a different behavior depending on - /// the configured compatibility version for the application. See for - /// guidance and examples of setting the application's compatibility version. - /// - /// - /// Configuring the desired value of the compatibility switch by calling this property's setter will take precedence - /// over the value implied by the application's . - /// - /// - /// If the application's compatibility version is set to then - /// this setting will have the value false unless explicitly configured. - /// - /// - /// If the application's compatibility version is set to or - /// higher then this setting will have the value true unless explicitly configured. - /// /// public bool AllowCombiningAuthorizeFilters { @@ -162,28 +126,11 @@ namespace Microsoft.AspNetCore.Mvc /// Gets or sets a value that determines if should bind to types other than /// or a collection of . If set to true, /// would bind to simple types (like , , - /// , etc.) or a collection of simple types. The default value of the - /// property is false. + /// , etc.) or a collection of simple types. /// - /// - /// - /// This property is associated with a compatibility switch and can provide a different behavior depending on - /// the configured compatibility version for the application. See for - /// guidance and examples of setting the application's compatibility version. - /// - /// - /// Configuring the desired value of the compatibility switch by calling this property's setter will take precedence - /// over the value implied by the application's . - /// - /// - /// If the application's compatibility version is set to then - /// this setting will have the value false unless explicitly configured. - /// - /// - /// If the application's compatibility version is set to or - /// higher then this setting will have the value true unless explicitly configured. - /// - /// + /// + /// The default value is . + /// public bool AllowBindingHeaderValuesToNonStringModelTypes { get => _allowBindingHeaderValuesToNonStringModelTypes.Value; @@ -197,28 +144,8 @@ namespace Microsoft.AspNetCore.Mvc /// ValidationAttributes on these top-level nodes are checked. Otherwise, such attributes are ignored. /// /// - /// The default value is if the version is - /// or later; otherwise. + /// The default value is . /// - /// - /// - /// This property is associated with a compatibility switch and can provide a different behavior depending on - /// the configured compatibility version for the application. See for - /// guidance and examples of setting the application's compatibility version. - /// - /// - /// Configuring the desired value of the compatibility switch by calling this property's setter will take - /// precedence over the value implied by the application's . - /// - /// - /// If the application's compatibility version is set to then - /// this setting will have the value unless explicitly configured. - /// - /// - /// If the application's compatibility version is set to or - /// higher then this setting will have the value unless explicitly configured. - /// - /// public bool AllowValidatingTopLevelNodes { get => _allowValidatingTopLevelNodes.Value; @@ -250,29 +177,10 @@ namespace Microsoft.AspNetCore.Mvc /// /// Gets or sets a value which determines how the model binding system interprets exceptions thrown by an . - /// The default value of the property is . /// - /// - /// - /// This property is associated with a compatibility switch and can provide a different behavior depending on - /// the configured compatibility version for the application. See for - /// guidance and examples of setting the application's compatibility version. - /// - /// - /// Configuring the desired value of the compatibility switch by calling this property's setter will take precedence - /// over the value implied by the application's . - /// - /// - /// If the application's compatibility version is set to then - /// this setting will have the value unless - /// explicitly configured. - /// - /// - /// If the application's compatibility version is set to or - /// higher then this setting will have the value - /// unless explicitly configured. - /// - /// + /// + /// The default value is . + /// public InputFormatterExceptionPolicy InputFormatterExceptionPolicy { get => _inputFormatterExceptionPolicy.Value; @@ -286,27 +194,11 @@ namespace Microsoft.AspNetCore.Mvc /// /// Gets or sets a value indicating whether the model binding system will bind undefined values to - /// enum types. The default value of the property is false. + /// enum types. /// - /// - /// - /// This property is associated with a compatibility switch and can provide a different behavior depending on - /// the configured compatibility version for the application. See for - /// guidance and examples of setting the application's compatibility version. - /// - /// - /// Configuring the desired value of the compatibility switch by calling this property's setter will take precedence - /// over the value implied by the application's . - /// - /// - /// If the application's compatibility version is set to then - /// this setting will have the value false unless explicitly configured. - /// - /// - /// If the application's compatibility version is set to or - /// higher then this setting will have the value true unless explicitly configured. - /// - /// + /// + /// The default value is . + /// public bool SuppressBindingUndefinedValueToEnumType { get => _suppressBindingUndefinedValueToEnumType.Value; @@ -413,24 +305,10 @@ namespace Microsoft.AspNetCore.Mvc /// When not , will throw if /// traversing an object exceeds the maximum allowed validation depth. /// - /// - /// This property is associated with a compatibility switch and can provide a different behavior depending on - /// the configured compatibility version for the application. See for - /// guidance and examples of setting the application's compatibility version. - /// - /// - /// Configuring the desired value of the compatibility switch by calling this property's setter will take precedence - /// over the value implied by the application's . - /// - /// - /// If the application's compatibility version is set to then - /// this setting will have the value 200 unless explicitly configured. - /// - /// - /// If the application's compatibility version is set to or - /// earlier then this setting will have the value unless explicitly configured. - /// /// + /// + /// The default value is 32. + /// public int? MaxValidationDepth { get => _maxValidationDepth.Value; @@ -450,8 +328,7 @@ namespace Microsoft.AspNetCore.Mvc /// can short-circuit validation when a model does not have any associated validators. /// /// - /// The default value is if the version is - /// or later; otherwise. + /// The default value is . /// /// /// When is , that is, it is determined @@ -459,23 +336,6 @@ namespace Microsoft.AspNetCore.Mvc /// can short-circuit validation for the model and mark the object /// graph as valid. Setting this property to , allows to /// perform this optimization. - /// - /// This property is associated with a compatibility switch and can provide a different behavior depending on - /// the configured compatibility version for the application. See for - /// guidance and examples of setting the application's compatibility version. - /// - /// - /// Configuring the desired value of the compatibility switch by calling this property's setter will take precedence - /// over the value implied by the application's . - /// - /// - /// If the application's compatibility version is set to then - /// this setting will have the value unless explicitly configured. - /// - /// - /// If the application's compatibility version is set to or - /// earlier then this setting will have the value unless explicitly configured. - /// /// public bool AllowShortCircuitingValidationWhenNoValidatorsArePresent { diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.DataAnnotations/DependencyInjection/MvcDataAnnotationsLocalizationConfigureCompatibilityOptions.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.DataAnnotations/DependencyInjection/MvcDataAnnotationsLocalizationConfigureCompatibilityOptions.cs index eb07025356..a5d0d4827f 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.DataAnnotations/DependencyInjection/MvcDataAnnotationsLocalizationConfigureCompatibilityOptions.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.DataAnnotations/DependencyInjection/MvcDataAnnotationsLocalizationConfigureCompatibilityOptions.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; -using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.DataAnnotations; using Microsoft.AspNetCore.Mvc.Infrastructure; using Microsoft.Extensions.Logging; @@ -23,14 +22,10 @@ namespace Microsoft.Extensions.DependencyInjection { get { - var values = new Dictionary(); - - if (Version >= CompatibilityVersion.Version_2_2) + return new Dictionary { - values[nameof(MvcDataAnnotationsLocalizationOptions.AllowDataAnnotationsLocalizationForEnumDisplayAttributes)] = true; - } - - return values; + [nameof(MvcDataAnnotationsLocalizationOptions.AllowDataAnnotationsLocalizationForEnumDisplayAttributes)] = true, + }; } } } diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.DataAnnotations/MvcDataAnnotationsLocalizationOptions.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.DataAnnotations/MvcDataAnnotationsLocalizationOptions.cs index 911c7139c6..2eb30c08b8 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.DataAnnotations/MvcDataAnnotationsLocalizationOptions.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.DataAnnotations/MvcDataAnnotationsLocalizationOptions.cs @@ -36,28 +36,13 @@ namespace Microsoft.AspNetCore.Mvc.DataAnnotations } /// - /// Gets or sets a value that determines if should be used while localizing types. - /// If set to true will be used in localizing types. + /// Gets or sets a value that determines if should be used while localizing types. + /// If set to true will be used in localizing types. /// If set to false the localization will search for values in resource files for the . /// - /// - /// - /// This property is associated with a compatibility switch and can provide a different behavior depending on - /// the configured compatibility version for the application. See for guidance and examples of setting the application's compatibility version. - /// - /// - /// Configuring the desired value of the compatibility switch by calling this property's setter will take precedence - /// over the value implied by the application's . - /// - /// - /// If the application's compatibility version is set to or then - /// this setting will have the value false unless explicitly configured. - /// - /// - /// If the application's compatibility version is set to or - /// higher then this setting will have the value true unless explicitly configured. - /// - /// + /// + /// The default value is . + /// public bool AllowDataAnnotationsLocalizationForEnumDisplayAttributes { get => _allowDataAnnotationsLocalizationForEnumDisplayAttributes.Value; diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Formatters.Json/DependencyInjection/MvcJsonOptionsConfigureCompatibilityOptions.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Formatters.Json/DependencyInjection/MvcJsonOptionsConfigureCompatibilityOptions.cs index 5fe4836b37..314550e61e 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Formatters.Json/DependencyInjection/MvcJsonOptionsConfigureCompatibilityOptions.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Formatters.Json/DependencyInjection/MvcJsonOptionsConfigureCompatibilityOptions.cs @@ -13,7 +13,7 @@ namespace Microsoft.Extensions.DependencyInjection { public MvcJsonOptionsConfigureCompatibilityOptions( ILoggerFactory loggerFactory, - IOptions compatibilityOptions) + IOptions compatibilityOptions) : base(loggerFactory, compatibilityOptions) { } @@ -22,14 +22,10 @@ namespace Microsoft.Extensions.DependencyInjection { get { - var values = new Dictionary(); - - if (Version >= CompatibilityVersion.Version_2_1) + return new Dictionary { - values[nameof(MvcJsonOptions.AllowInputFormatterExceptionMessages)] = true; - } - - return values; + [nameof(MvcJsonOptions.AllowInputFormatterExceptionMessages)] = true, + }; } } } diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Formatters.Json/MvcJsonOptions.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Formatters.Json/MvcJsonOptions.cs index 28df9825b5..2d2ce11687 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Formatters.Json/MvcJsonOptions.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Formatters.Json/MvcJsonOptions.cs @@ -32,33 +32,17 @@ namespace Microsoft.AspNetCore.Mvc } /// - /// Gets or sets a flag to determine whether error messages from JSON deserialization by the - /// will be added to the . The default - /// value is false, meaning that a generic error message will be used instead. + /// Gets or sets a flag to determine whether error messages from JSON deserialization by the + /// will be added to the . If + /// , a generic error message will be used instead. /// + /// + /// The default value is . + /// /// - /// /// Error messages in the are often communicated to clients, either in HTML /// or using . In effect, this setting controls whether clients can receive /// detailed error messages about submitted JSON data. - /// - /// - /// This property is associated with a compatibility switch and can provide a different behavior depending on - /// the configured compatibility version for the application. See for - /// guidance and examples of setting the application's compatibility version. - /// - /// - /// Configuring the desired of the value compatibility switch by calling this property's setter will take precedence - /// over the value implied by the application's . - /// - /// - /// If the application's compatibility version is set to then - /// this setting will have value false unless explicitly configured. - /// - /// - /// If the application's compatibility version is set to or - /// higher then this setting will have value true unless explicitly configured. - /// /// public bool AllowInputFormatterExceptionMessages { @@ -78,4 +62,4 @@ namespace Microsoft.AspNetCore.Mvc IEnumerator IEnumerable.GetEnumerator() => _switches.GetEnumerator(); } -} \ No newline at end of file +} diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Formatters.Xml/DependencyInjection/MvcXmlOptionsConfigureCompatibilityOptions.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Formatters.Xml/DependencyInjection/MvcXmlOptionsConfigureCompatibilityOptions.cs index d37e67d3e1..94a37643d5 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Formatters.Xml/DependencyInjection/MvcXmlOptionsConfigureCompatibilityOptions.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Formatters.Xml/DependencyInjection/MvcXmlOptionsConfigureCompatibilityOptions.cs @@ -2,7 +2,6 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; -using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Formatters.Xml; using Microsoft.AspNetCore.Mvc.Infrastructure; using Microsoft.Extensions.Logging; @@ -14,7 +13,7 @@ namespace Microsoft.Extensions.DependencyInjection { public MvcXmlOptionsConfigureCompatibilityOptions( ILoggerFactory loggerFactory, - IOptions compatibilityOptions) + IOptions compatibilityOptions) : base(loggerFactory, compatibilityOptions) { } @@ -23,14 +22,10 @@ namespace Microsoft.Extensions.DependencyInjection { get { - var values = new Dictionary(); - - if (Version >= CompatibilityVersion.Version_2_2) + return new Dictionary { - values[nameof(MvcXmlOptions.AllowRfc7807CompliantProblemDetailsFormat)] = true; - } - - return values; + [nameof(MvcXmlOptions.AllowRfc7807CompliantProblemDetailsFormat)] = true, + }; } } } diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Formatters.Xml/MvcXmlOptions.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Formatters.Xml/MvcXmlOptions.cs index d8ada74590..c9868616b6 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.Formatters.Xml/MvcXmlOptions.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.Formatters.Xml/MvcXmlOptions.cs @@ -33,28 +33,8 @@ namespace Microsoft.AspNetCore.Mvc.Formatters.Xml /// are serialized in a format compliant with the RFC 7807 specification (https://tools.ietf.org/html/rfc7807). /// /// - /// The default value is if the version is - /// or later; otherwise. + /// The default value is . /// - /// - /// - /// This property is associated with a compatibility switch and can provide a different behavior depending on - /// the configured compatibility version for the application. See for - /// guidance and examples of setting the application's compatibility version. - /// - /// - /// Configuring the desired value of the compatibility switch by calling this property's setter will take - /// precedence over the value implied by the application's . - /// - /// - /// If the application's compatibility version is set to or - /// lower then this setting will have the value unless explicitly configured. - /// - /// - /// If the application's compatibility version is set to or - /// higher then this setting will have the value unless explicitly configured. - /// - /// public bool AllowRfc7807CompliantProblemDetailsFormat { get => _allowRfc7807CompliantProblemDetailsFormat.Value; diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.RazorPages/RazorPagesOptions.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.RazorPages/RazorPagesOptions.cs index 38bd6f7988..3718b3df28 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.RazorPages/RazorPagesOptions.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.RazorPages/RazorPagesOptions.cs @@ -66,30 +66,13 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages /// /// Gets or sets a value that determines if areas are enabled for Razor Pages. - /// Defaults to false. /// + /// + /// The default value is . + /// /// - /// /// When enabled, any Razor Page under the directory structure /Area/AreaName/Pages/ /// will be associated with an area with the name AreaName. - /// - /// - /// This property is associated with a compatibility switch and can provide a different behavior depending on - /// the configured compatibility version for the application. See for - /// guidance and examples of setting the application's compatibility version. - /// - /// - /// Configuring the desired of the value compatibility switch by calling this property's setter will take precedence - /// over the value implied by the application's . - /// - /// - /// If the application's compatibility version is set to then - /// this setting will have value false unless explicitly configured. - /// - /// - /// If the application's compatibility version is set to or - /// higher then this setting will have value true unless explicitly configured. - /// /// public bool AllowAreas { @@ -100,36 +83,21 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages /// /// Gets or sets a value that determines if HTTP method matching for Razor Pages handler methods will use /// fuzzy matching. - /// Defaults to false. /// + /// + /// The default value is . + /// /// /// /// When enabled, Razor Pages handler methods will be more flexible in which HTTP methods will be accepted - /// by GET and POST handler methods. This allows a GET handler methods to accept the HEAD HTTP methods in - /// addition to GET. A more specific handler method can still be defined to accept HEAD, and the most + /// by GET and POST handler methods. This allows a GET handler methods to accept the HEAD HTTP methods in + /// addition to GET. A more specific handler method can still be defined to accept HEAD, and the most /// specific handler will be invoked. /// /// /// This setting reduces the number of handler methods that must be written to correctly respond to typical /// web traffic including requests from internet infrastructure such as web crawlers. /// - /// - /// This property is associated with a compatibility switch and can provide a different behavior depending on - /// the configured compatibility version for the application. See for - /// guidance and examples of setting the application's compatibility version. - /// - /// - /// Configuring the desired of the value compatibility switch by calling this property's setter will take precedence - /// over the value implied by the application's . - /// - /// - /// If the application's compatibility version is set to then - /// this setting will have value false unless explicitly configured. - /// - /// - /// If the application's compatibility version is set to or - /// higher then this setting will have value true unless explicitly configured. - /// /// public bool AllowMappingHeadRequestsToGetHandler { @@ -142,33 +110,13 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages /// no handler is available. /// /// - /// The default value is if the version is - /// or later; otherwise. + /// The default value is . /// /// - /// /// Razor Pages uses the current request's HTTP method to select a handler method. When no handler is available or selected, /// the page is immediately executed. This may cause runtime errors if the page relies on the handler method to execute /// and initialize some state. This setting attempts to avoid this class of error for HTTP OPTIONS requests by /// returning a 200 OK response. - /// - /// - /// This property is associated with a compatibility switch and can provide a different behavior depending on - /// the configured compatibility version for the application. See for - /// guidance and examples of setting the application's compatibility version. - /// - /// - /// Configuring the desired of the value compatibility switch by calling this property's setter will take precedence - /// over the value implied by the application's . - /// - /// - /// If the application's compatibility version is set to then - /// this setting will have value true unless explicitly configured. - /// - /// - /// If the application's compatibility version is set to or - /// lower then this setting will have value true unless explicitly configured. - /// /// public bool AllowDefaultHandlingForOptionsRequests { @@ -183,4 +131,4 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages IEnumerator IEnumerable.GetEnumerator() => _switches.GetEnumerator(); } -} \ No newline at end of file +} diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.RazorPages/RazorPagesOptionsConfigureCompatibilityOptions.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.RazorPages/RazorPagesOptionsConfigureCompatibilityOptions.cs index 49596d55b2..6b21a8ee6f 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.RazorPages/RazorPagesOptionsConfigureCompatibilityOptions.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.RazorPages/RazorPagesOptionsConfigureCompatibilityOptions.cs @@ -12,7 +12,7 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages { public RazorPagesOptionsConfigureCompatibilityOptions( ILoggerFactory loggerFactory, - IOptions compatibilityOptions) + IOptions compatibilityOptions) : base(loggerFactory, compatibilityOptions) { } @@ -21,20 +21,12 @@ namespace Microsoft.AspNetCore.Mvc.RazorPages { get { - var values = new Dictionary(); - - if (Version >= CompatibilityVersion.Version_2_1) + return new Dictionary { - values[nameof(RazorPagesOptions.AllowAreas)] = true; - values[nameof(RazorPagesOptions.AllowMappingHeadRequestsToGetHandler)] = true; - } - - if (Version >= CompatibilityVersion.Version_2_2) - { - values[nameof(RazorPagesOptions.AllowDefaultHandlingForOptionsRequests)] = true; - } - - return values; + [nameof(RazorPagesOptions.AllowAreas)] = true, + [nameof(RazorPagesOptions.AllowMappingHeadRequestsToGetHandler)] = true, + [nameof(RazorPagesOptions.AllowDefaultHandlingForOptionsRequests)] = true, + }; } } } diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.ViewFeatures/MvcViewOptions.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.ViewFeatures/MvcViewOptions.cs index 237777da23..1fe4f28adf 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.ViewFeatures/MvcViewOptions.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.ViewFeatures/MvcViewOptions.cs @@ -62,29 +62,10 @@ namespace Microsoft.AspNetCore.Mvc /// e.g. TempDataProperty-SuccessMessage. When this option is true, the calculated key for the property is /// the property name e.g. SuccessMessage. /// - /// - /// Defaults to false. - /// /// - /// - /// - /// This property is associated with a compatibility switch and can provide a different behavior depending on - /// the configured compatibility version for the application. See for - /// guidance and examples of setting the application's compatibility version. - /// - /// - /// Configuring the desired value of the compatibility switch by calling this property's setter will take precedence - /// over the value implied by the application's . - /// - /// - /// If the application's compatibility version is set to then - /// this setting will have the value false unless explicitly configured. - /// - /// - /// If the application's compatibility version is set to or - /// higher then this setting will have the value true unless explicitly configured. - /// - /// + /// + /// The default value is . + /// public bool SuppressTempDataAttributePrefix { get => _suppressTempDataAttributePrefix.Value; @@ -96,7 +77,12 @@ namespace Microsoft.AspNetCore.Mvc /// when they're bound to models marked with either /// or attributes. /// - /// If both attributes are specified, the one with the smaller value will be used for the rendered `maxlength` attribute. + /// + /// The default value is . + /// + /// + /// If both attributes are specified, the one with the smaller value will be used for the rendered `maxlength` attribute. + /// public bool AllowRenderingMaxLengthAttribute { get => _allowRenderingMaxLengthAttribute.Value; @@ -121,4 +107,4 @@ namespace Microsoft.AspNetCore.Mvc IEnumerator IEnumerable.GetEnumerator() => _switches.GetEnumerator(); } -} \ No newline at end of file +} diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.ViewFeatures/MvcViewOptionsConfigureCompatibilityOptions.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.ViewFeatures/MvcViewOptionsConfigureCompatibilityOptions.cs index b17210f7de..67e4b7bb52 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.ViewFeatures/MvcViewOptionsConfigureCompatibilityOptions.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.ViewFeatures/MvcViewOptionsConfigureCompatibilityOptions.cs @@ -21,19 +21,11 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures { get { - var values = new Dictionary(); - - if (Version >= CompatibilityVersion.Version_2_1) + return new Dictionary { - values[nameof(MvcViewOptions.SuppressTempDataAttributePrefix)] = true; - } - - if (Version >= CompatibilityVersion.Version_2_2) - { - values[nameof(MvcViewOptions.AllowRenderingMaxLengthAttribute)] = true; - } - - return values; + [nameof(MvcViewOptions.SuppressTempDataAttributePrefix)] = true, + [nameof(MvcViewOptions.AllowRenderingMaxLengthAttribute)] = true, + }; } } } diff --git a/src/Mvc/src/Microsoft.AspNetCore.Mvc.ViewFeatures/TemplateInfo.cs b/src/Mvc/src/Microsoft.AspNetCore.Mvc.ViewFeatures/TemplateInfo.cs index 76abaa2389..1694943821 100644 --- a/src/Mvc/src/Microsoft.AspNetCore.Mvc.ViewFeatures/TemplateInfo.cs +++ b/src/Mvc/src/Microsoft.AspNetCore.Mvc.ViewFeatures/TemplateInfo.cs @@ -31,11 +31,11 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures /// /// Gets or sets the formatted model value. /// + /// The formatted model value. /// /// Will never return null to avoid problems when using HTML helpers within a template. Otherwise the /// helpers could find elements in the `ViewDataDictionary`, not the intended Model properties. /// - /// The formatted model value. public object FormattedModelValue { get { return _formattedModelValue; } @@ -45,10 +45,10 @@ namespace Microsoft.AspNetCore.Mvc.ViewFeatures /// /// Gets or sets the HTML field prefix. /// + /// The HTML field prefix. /// /// Will never return null for consistency with . /// - /// The HTML field prefix. public string HtmlFieldPrefix { get { return _htmlFieldPrefix; } diff --git a/src/Mvc/test/Microsoft.AspNetCore.Mvc.Core.Test/DependencyInjection/ApiBehaviorOptionsSetupTest.cs b/src/Mvc/test/Microsoft.AspNetCore.Mvc.Core.Test/DependencyInjection/ApiBehaviorOptionsSetupTest.cs index 4255b344ea..a6b60a027b 100644 --- a/src/Mvc/test/Microsoft.AspNetCore.Mvc.Core.Test/DependencyInjection/ApiBehaviorOptionsSetupTest.cs +++ b/src/Mvc/test/Microsoft.AspNetCore.Mvc.Core.Test/DependencyInjection/ApiBehaviorOptionsSetupTest.cs @@ -64,23 +64,6 @@ namespace Microsoft.Extensions.DependencyInjection Assert.Same(ApiBehaviorOptionsSetup.ProblemDetailsFactory, options.InvalidModelStateResponseFactory); } - [Fact] - public void PostConfigure_DoesNotSetProblemDetailsFactoryWithLegacyCompatBehavior() - { - // Arrange - var optionsSetup = new ApiBehaviorOptionsSetup( - NullLoggerFactory.Instance, - Options.Options.Create(new MvcCompatibilityOptions { CompatibilityVersion = CompatibilityVersion.Version_2_1 })); - var options = new ApiBehaviorOptions(); - - // Act - optionsSetup.Configure(options); - optionsSetup.PostConfigure(string.Empty, options); - - // Assert - Assert.Same(ApiBehaviorOptionsSetup.DefaultFactory, options.InvalidModelStateResponseFactory); - } - [Fact] public void PostConfigure_DoesNotSetProblemDetailsFactory_IfValueWasModified() { diff --git a/src/Mvc/test/Microsoft.AspNetCore.Mvc.Core.Test/Infrastructure/ConfigureCompatibilityOptionsTest.cs b/src/Mvc/test/Microsoft.AspNetCore.Mvc.Core.Test/Infrastructure/ConfigureCompatibilityOptionsTest.cs index a666303be8..5c81fbf66d 100644 --- a/src/Mvc/test/Microsoft.AspNetCore.Mvc.Core.Test/Infrastructure/ConfigureCompatibilityOptionsTest.cs +++ b/src/Mvc/test/Microsoft.AspNetCore.Mvc.Core.Test/Infrastructure/ConfigureCompatibilityOptionsTest.cs @@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure public void PostConfigure_NoValueForProperty_DoesNothing() { // Arrange - var configure = Create(CompatibilityVersion.Version_2_0, new Dictionary()); + var configure = Create(CompatibilityVersion.Version_3_0, new Dictionary()); var options = new TestOptions(); @@ -31,10 +31,12 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure public void PostConfigure_ValueIsSet_DoesNothing() { // Arrange - var configure = Create(CompatibilityVersion.Version_2_0, new Dictionary() - { - { nameof(TestOptions.TestProperty), true }, - }); + var configure = Create( + CompatibilityVersion.Version_3_0, + new Dictionary + { + { nameof(TestOptions.TestProperty), true }, + }); var options = new TestOptions() { @@ -52,10 +54,12 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure public void PostConfigure_ValueNotSet_SetsValue() { // Arrange - var configure = Create(CompatibilityVersion.Version_2_0, new Dictionary() - { - { nameof(TestOptions.TestProperty), true }, - }); + var configure = Create( + CompatibilityVersion.Version_3_0, + new Dictionary + { + { nameof(TestOptions.TestProperty), true }, + }); var options = new TestOptions(); @@ -67,7 +71,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure } private static ConfigureCompatibilityOptions Create( - CompatibilityVersion version, + CompatibilityVersion version, IReadOnlyDictionary defaultValues) { var compatibilityOptions = Options.Create(new MvcCompatibilityOptions() { CompatibilityVersion = version }); @@ -105,7 +109,7 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure public TestConfigure( ILoggerFactory loggerFactory, IOptions compatibilityOptions, - IReadOnlyDictionary defaultValues) + IReadOnlyDictionary defaultValues) : base(loggerFactory, compatibilityOptions) { DefaultValues = defaultValues; diff --git a/src/Mvc/test/Microsoft.AspNetCore.Mvc.Core.Test/Infrastructure/MvcOptionsConfigureCompatibilityOptionsTest.cs b/src/Mvc/test/Microsoft.AspNetCore.Mvc.Core.Test/Infrastructure/MvcOptionsConfigureCompatibilityOptionsTest.cs index d661fe0bd5..2fd9c3792c 100644 --- a/src/Mvc/test/Microsoft.AspNetCore.Mvc.Core.Test/Infrastructure/MvcOptionsConfigureCompatibilityOptionsTest.cs +++ b/src/Mvc/test/Microsoft.AspNetCore.Mvc.Core.Test/Infrastructure/MvcOptionsConfigureCompatibilityOptionsTest.cs @@ -17,7 +17,7 @@ namespace Microsoft.AspNetCore.Mvc.Core.Infrastructure var mvcOptions = new MvcOptions(); var mvcCompatibilityOptions = new MvcCompatibilityOptions { - CompatibilityVersion = CompatibilityVersion.Version_2_2, + CompatibilityVersion = CompatibilityVersion.Version_3_0, }; var configureOptions = new MvcOptionsConfigureCompatibilityOptions( @@ -41,7 +41,7 @@ namespace Microsoft.AspNetCore.Mvc.Core.Infrastructure }; var mvcCompatibilityOptions = new MvcCompatibilityOptions { - CompatibilityVersion = CompatibilityVersion.Version_2_2, + CompatibilityVersion = CompatibilityVersion.Version_3_0, }; var configureOptions = new MvcOptionsConfigureCompatibilityOptions( @@ -66,7 +66,7 @@ namespace Microsoft.AspNetCore.Mvc.Core.Infrastructure }; var mvcCompatibilityOptions = new MvcCompatibilityOptions { - CompatibilityVersion = CompatibilityVersion.Version_2_2, + CompatibilityVersion = CompatibilityVersion.Version_3_0, }; var configureOptions = new MvcOptionsConfigureCompatibilityOptions( diff --git a/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/CorsEndpointRoutingTests.cs b/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/CorsEndpointRoutingTests.cs index 82867e6ed5..1fd1de6403 100644 --- a/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/CorsEndpointRoutingTests.cs +++ b/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/CorsEndpointRoutingTests.cs @@ -9,5 +9,5 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests : base(fixture) { } - } -} \ No newline at end of file + } +} diff --git a/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/CorsTests.cs b/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/CorsTests.cs index 512fc5ea90..a913965c8b 100644 --- a/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/CorsTests.cs +++ b/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/CorsTests.cs @@ -9,9 +9,9 @@ using Xunit; namespace Microsoft.AspNetCore.Mvc.FunctionalTests { - public class CorsTests : CorsTestsBase + public class CorsTests : CorsTestsBase { - public CorsTests(MvcTestFixture fixture) + public CorsTests(MvcTestFixture fixture) : base(fixture) { } @@ -31,4 +31,4 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); } } -} \ No newline at end of file +} diff --git a/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/CorsTestsBase.cs b/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/CorsTestsBase.cs index 41687b9c5f..e04b7cc3e1 100644 --- a/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/CorsTestsBase.cs +++ b/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/CorsTestsBase.cs @@ -404,4 +404,4 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests Assert.Empty(content); } } -} \ No newline at end of file +} diff --git a/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/GlobalAuthorizationFilterTest.cs b/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/GlobalAuthorizationFilterTest.cs index 5ac55864af..01ba176748 100644 --- a/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/GlobalAuthorizationFilterTest.cs +++ b/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/GlobalAuthorizationFilterTest.cs @@ -53,34 +53,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests } [Fact] - public async Task AuthorizationPoliciesDoNotCombine_WithV2_0() - { - // Arrange & Act - var client = Factory - .WithWebHostBuilder(builder => builder.UseStartup()) - .CreateDefaultClient(); - var response = await client.PostAsync("http://localhost/Administration/SignInCookie2", null); - - // Assert - Assert.Equal(HttpStatusCode.OK, response.StatusCode); - Assert.True(response.Headers.Contains("Set-Cookie")); - - var cookie2 = response.Headers.GetValues("Set-Cookie").SingleOrDefault(); - - var request = new HttpRequestMessage(HttpMethod.Get, "http://localhost/Administration/EitherCookie"); - request.Headers.Add("Cookie", cookie2); - - // Will fail because default cookie is not sent so [Authorize] fails. - response = await client.SendAsync(request); - Assert.Equal(HttpStatusCode.Redirect, response.StatusCode); - Assert.NotNull(response.Headers.Location); - Assert.Equal( - "http://localhost/Home/Login?ReturnUrl=%2FAdministration%2FEitherCookie", - response.Headers.Location.ToString()); - } - - [Fact] - public async Task AuthorizationPoliciesCombine_WithV2_1() + public async Task AuthorizationPoliciesCombine() { // Arrange & Act 1 var response = await Client.PostAsync("http://localhost/Administration/SignInCookie2", null); diff --git a/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/HtmlGenerationTest.cs b/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/HtmlGenerationTest.cs index 1f7e18760b..4288fbff8c 100644 --- a/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/HtmlGenerationTest.cs +++ b/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/HtmlGenerationTest.cs @@ -143,7 +143,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests { // Arrange var client = Factory - .WithWebHostBuilder(builder => builder.UseStartup()) + .WithWebHostBuilder(builder => builder.UseStartup()) .CreateDefaultClient(); var expectedMediaType = MediaTypeHeaderValue.Parse("text/html; charset=utf-8"); var outputFile = "compiler/resources/HtmlGenerationWebSite.HtmlGeneration_Home.Index21Compat.html"; diff --git a/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/RoutingTests.cs b/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/RoutingTests.cs index b3523419c5..a6fb8f2308 100644 --- a/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/RoutingTests.cs +++ b/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/RoutingTests.cs @@ -10,9 +10,9 @@ using Xunit; namespace Microsoft.AspNetCore.Mvc.FunctionalTests { - public class RoutingTests : RoutingTestsBase + public class RoutingTests : RoutingTestsBase { - public RoutingTests(MvcTestFixture fixture) + public RoutingTests(MvcTestFixture fixture) : base(fixture) { } diff --git a/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/VersioningEndpointRoutingTests.cs b/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/VersioningEndpointRoutingTests.cs index 30f2ea33ba..890fcce2fc 100644 --- a/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/VersioningEndpointRoutingTests.cs +++ b/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/VersioningEndpointRoutingTests.cs @@ -72,4 +72,4 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests Assert.Equal("Post", result.Action); } } -} \ No newline at end of file +} diff --git a/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/VersioningTests.cs b/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/VersioningTests.cs index 80e057bbd1..4efc0561a4 100644 --- a/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/VersioningTests.cs +++ b/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/VersioningTests.cs @@ -8,9 +8,9 @@ using Xunit; namespace Microsoft.AspNetCore.Mvc.FunctionalTests { - public class VersioningTests : VersioningTestsBase + public class VersioningTests : VersioningTestsBase { - public VersioningTests(MvcTestFixture fixture) + public VersioningTests(MvcTestFixture fixture) : base(fixture) { } @@ -30,4 +30,4 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests Assert.False(result); } } -} \ No newline at end of file +} diff --git a/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/VersioningTestsBase.cs b/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/VersioningTestsBase.cs index a2b7c36325..4a0757316a 100644 --- a/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/VersioningTestsBase.cs +++ b/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/VersioningTestsBase.cs @@ -568,4 +568,4 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests public string Link { get; set; } } } -} \ No newline at end of file +} diff --git a/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/XmlDataContractSerializerFormattersWrappingTest.cs b/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/XmlDataContractSerializerFormattersWrappingTest.cs index 5c781c6652..a0f5027053 100644 --- a/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/XmlDataContractSerializerFormattersWrappingTest.cs +++ b/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/XmlDataContractSerializerFormattersWrappingTest.cs @@ -16,9 +16,9 @@ using Xunit; namespace Microsoft.AspNetCore.Mvc.FunctionalTests { - public class XmlDataContractSerializerFormattersWrappingTest : IClassFixture> + public class XmlDataContractSerializerFormattersWrappingTest : IClassFixture> { - public XmlDataContractSerializerFormattersWrappingTest(MvcTestFixture fixture) + public XmlDataContractSerializerFormattersWrappingTest(MvcTestFixture fixture) { Factory = fixture.Factories.FirstOrDefault() ?? fixture.WithWebHostBuilder(builder => builder.UseStartup()); Client = Factory.CreateDefaultClient(); @@ -260,31 +260,6 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests XmlAssert.Equal(expected, content); } - [Fact] - public async Task ProblemDetails_With21Behavior() - { - // Arrange - var expected = "" + - "instance" + - "404" + - "title" + - "correlation" + - "Account1 Account2" + - ""; - - var client = Factory - .WithWebHostBuilder(builder => builder.UseStartup()) - .CreateDefaultClient(); - - // Act - var response = await client.GetAsync("/api/XmlDataContractApi/ActionReturningProblemDetails"); - - // Assert - await response.AssertStatusCodeAsync(HttpStatusCode.NotFound); - var content = await response.Content.ReadAsStringAsync(); - XmlAssert.Equal(expected, content); - } - [Fact] public async Task ValidationProblemDetails_IsSerialized() { @@ -333,33 +308,5 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests var content = await response.Content.ReadAsStringAsync(); XmlAssert.Equal(expected, content); } - - [Fact] - public async Task ValidationProblemDetails_With21Behavior() - { - // Arrange - var expected = "" + - "some detail" + - "400" + - "One or more validation errors occurred." + - "some type" + - "correlation" + - "" + - "ErrorValue" + - "" + - ""; - - var client = Factory - .WithWebHostBuilder(builder => builder.UseStartup()) - .CreateDefaultClient(); - - // Act - var response = await client.GetAsync("/api/XmlDataContractApi/ActionReturningValidationDetailsWithMetadata"); - - // Assert - await response.AssertStatusCodeAsync(HttpStatusCode.BadRequest); - var content = await response.Content.ReadAsStringAsync(); - XmlAssert.Equal(expected, content); - } } } diff --git a/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/XmlSerializerFormattersWrappingTest.cs b/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/XmlSerializerFormattersWrappingTest.cs index 542941cfb8..1fa99687d5 100644 --- a/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/XmlSerializerFormattersWrappingTest.cs +++ b/src/Mvc/test/Microsoft.AspNetCore.Mvc.FunctionalTests/XmlSerializerFormattersWrappingTest.cs @@ -15,9 +15,9 @@ using Xunit; namespace Microsoft.AspNetCore.Mvc.FunctionalTests { - public class XmlSerializerFormattersWrappingTest : IClassFixture> + public class XmlSerializerFormattersWrappingTest : IClassFixture> { - public XmlSerializerFormattersWrappingTest(MvcTestFixture fixture) + public XmlSerializerFormattersWrappingTest(MvcTestFixture fixture) { Factory = fixture.Factories.FirstOrDefault() ?? fixture.WithWebHostBuilder(builder => builder.UseStartup()); Client = Factory.CreateDefaultClient(); @@ -214,31 +214,6 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests } } - [Fact] - public async Task ProblemDetails_With21Behavior() - { - // Arrange - var expected = "" + - "instance" + - "404" + - "title" + - "correlation" + - "Account1 Account2" + - ""; - - var client = Factory - .WithWebHostBuilder(builder => builder.UseStartup()) - .CreateDefaultClient(); - - // Act - var response = await client.GetAsync("/api/XmlSerializerApi/ActionReturningProblemDetails"); - - // Assert - await response.AssertStatusCodeAsync(HttpStatusCode.NotFound); - var content = await response.Content.ReadAsStringAsync(); - XmlAssert.Equal(expected, content); - } - [Fact] public async Task ProblemDetails_WithExtensionMembers_IsSerialized() { @@ -308,33 +283,5 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests var content = await response.Content.ReadAsStringAsync(); XmlAssert.Equal(expected, content); } - - [Fact] - public async Task ValidationProblemDetails_With21Behavior() - { - // Arrange - var expected = "" + - "some detail" + - "400" + - "One or more validation errors occurred." + - "some type" + - "correlation" + - "" + - "ErrorValue" + - "" + - ""; - - var client = Factory - .WithWebHostBuilder(builder => builder.UseStartup()) - .CreateDefaultClient(); - - // Act - var response = await client.GetAsync("/api/XmlSerializerApi/ActionReturningValidationDetailsWithMetadata"); - - // Assert - await response.AssertStatusCodeAsync(HttpStatusCode.BadRequest); - var content = await response.Content.ReadAsStringAsync(); - XmlAssert.Equal(expected, content); - } } } diff --git a/src/Mvc/test/Microsoft.AspNetCore.Mvc.IntegrationTests/ModelBindingTestHelper.cs b/src/Mvc/test/Microsoft.AspNetCore.Mvc.IntegrationTests/ModelBindingTestHelper.cs index 3a882567d0..f1b1c9fe0b 100644 --- a/src/Mvc/test/Microsoft.AspNetCore.Mvc.IntegrationTests/ModelBindingTestHelper.cs +++ b/src/Mvc/test/Microsoft.AspNetCore.Mvc.IntegrationTests/ModelBindingTestHelper.cs @@ -191,9 +191,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTests serviceCollection.AddSingleton(Options.Create(mvcOptions)); } - serviceCollection - .AddMvc() - .SetCompatibilityVersion(CompatibilityVersion.Version_2_1); + serviceCollection.AddMvc(); serviceCollection .AddSingleton() .AddSingleton(NullLoggerFactory.Instance) diff --git a/src/Mvc/test/Microsoft.AspNetCore.Mvc.Test/IntegrationTest/CompatibilitySwitchIntegrationTest.cs b/src/Mvc/test/Microsoft.AspNetCore.Mvc.Test/IntegrationTest/CompatibilitySwitchIntegrationTest.cs index ca8d894665..865b51266d 100644 --- a/src/Mvc/test/Microsoft.AspNetCore.Mvc.Test/IntegrationTest/CompatibilitySwitchIntegrationTest.cs +++ b/src/Mvc/test/Microsoft.AspNetCore.Mvc.Test/IntegrationTest/CompatibilitySwitchIntegrationTest.cs @@ -22,7 +22,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTest public class CompatibilitySwitchIntegrationTest { [Fact] - public void CompatibilitySwitches_Version_2_0() + public void CompatibilitySwitches_Version_3_0() { // Arrange var serviceCollection = new ServiceCollection(); @@ -30,83 +30,7 @@ namespace Microsoft.AspNetCore.Mvc.IntegrationTest serviceCollection .AddMvc() .AddXmlDataContractSerializerFormatters() - .SetCompatibilityVersion(CompatibilityVersion.Version_2_0); - - var services = serviceCollection.BuildServiceProvider(); - - // Act - var mvcOptions = services.GetRequiredService>().Value; - var jsonOptions = services.GetRequiredService>().Value; - var razorPagesOptions = services.GetRequiredService>().Value; - var apiBehaviorOptions = services.GetRequiredService>().Value; - var razorViewEngineOptions = services.GetRequiredService>().Value; - var xmlOptions = services.GetRequiredService>().Value; - - // Assert - Assert.False(mvcOptions.AllowCombiningAuthorizeFilters); - Assert.False(mvcOptions.AllowBindingHeaderValuesToNonStringModelTypes); - Assert.False(mvcOptions.SuppressBindingUndefinedValueToEnumType); - Assert.Equal(InputFormatterExceptionPolicy.AllExceptions, mvcOptions.InputFormatterExceptionPolicy); - Assert.False(jsonOptions.AllowInputFormatterExceptionMessages); - Assert.False(razorPagesOptions.AllowAreas); - Assert.False(mvcOptions.EnableEndpointRouting); - Assert.Null(mvcOptions.MaxValidationDepth); - Assert.True(apiBehaviorOptions.SuppressUseValidationProblemDetailsForInvalidModelStateResponses); - Assert.True(apiBehaviorOptions.SuppressMapClientErrors); - Assert.False(razorPagesOptions.AllowDefaultHandlingForOptionsRequests); - Assert.False(xmlOptions.AllowRfc7807CompliantProblemDetailsFormat); - Assert.False(mvcOptions.AllowShortCircuitingValidationWhenNoValidatorsArePresent); - Assert.True(apiBehaviorOptions.AllowInferringBindingSourceForCollectionTypesAsFromQuery); - } - - [Fact] - public void CompatibilitySwitches_Version_2_1() - { - // Arrange - var serviceCollection = new ServiceCollection(); - AddHostingServices(serviceCollection); - serviceCollection - .AddMvc() - .AddXmlDataContractSerializerFormatters() - .SetCompatibilityVersion(CompatibilityVersion.Version_2_1); - - var services = serviceCollection.BuildServiceProvider(); - - // Act - var mvcOptions = services.GetRequiredService>().Value; - var jsonOptions = services.GetRequiredService>().Value; - var razorPagesOptions = services.GetRequiredService>().Value; - var apiBehaviorOptions = services.GetRequiredService>().Value; - var razorViewEngineOptions = services.GetRequiredService>().Value; - var xmlOptions = services.GetRequiredService>().Value; - - // Assert - Assert.True(mvcOptions.AllowCombiningAuthorizeFilters); - Assert.True(mvcOptions.AllowBindingHeaderValuesToNonStringModelTypes); - Assert.True(mvcOptions.SuppressBindingUndefinedValueToEnumType); - Assert.Equal(InputFormatterExceptionPolicy.MalformedInputExceptions, mvcOptions.InputFormatterExceptionPolicy); - Assert.True(jsonOptions.AllowInputFormatterExceptionMessages); - Assert.True(razorPagesOptions.AllowAreas); - Assert.False(mvcOptions.EnableEndpointRouting); - Assert.Null(mvcOptions.MaxValidationDepth); - Assert.True(apiBehaviorOptions.SuppressUseValidationProblemDetailsForInvalidModelStateResponses); - Assert.True(apiBehaviorOptions.SuppressMapClientErrors); - Assert.False(razorPagesOptions.AllowDefaultHandlingForOptionsRequests); - Assert.False(xmlOptions.AllowRfc7807CompliantProblemDetailsFormat); - Assert.False(mvcOptions.AllowShortCircuitingValidationWhenNoValidatorsArePresent); - Assert.True(apiBehaviorOptions.AllowInferringBindingSourceForCollectionTypesAsFromQuery); - } - - [Fact] - public void CompatibilitySwitches_Version_2_2() - { - // Arrange - var serviceCollection = new ServiceCollection(); - AddHostingServices(serviceCollection); - serviceCollection - .AddMvc() - .AddXmlDataContractSerializerFormatters() - .SetCompatibilityVersion(CompatibilityVersion.Version_2_2); + .SetCompatibilityVersion(CompatibilityVersion.Version_3_0); var services = serviceCollection.BuildServiceProvider(); diff --git a/src/Mvc/test/WebSites/CorsWebSite/Startup.cs b/src/Mvc/test/WebSites/CorsWebSite/Startup.cs index 6ef084b83b..8759aa6922 100644 --- a/src/Mvc/test/WebSites/CorsWebSite/Startup.cs +++ b/src/Mvc/test/WebSites/CorsWebSite/Startup.cs @@ -12,7 +12,7 @@ namespace CorsWebSite { public void ConfigureServices(IServiceCollection services) { - services.AddMvc() + services.AddMvc(ConfigureMvcOptions) .SetCompatibilityVersion(CompatibilityVersion.Latest); services.Configure(options => { @@ -76,5 +76,9 @@ namespace CorsWebSite { app.UseMvc(); } + + protected virtual void ConfigureMvcOptions(MvcOptions options) + { + } } } diff --git a/src/Mvc/test/WebSites/CorsWebSite/StartupWith21Compat.cs b/src/Mvc/test/WebSites/CorsWebSite/StartupWith21Compat.cs deleted file mode 100644 index b34b71f80c..0000000000 --- a/src/Mvc/test/WebSites/CorsWebSite/StartupWith21Compat.cs +++ /dev/null @@ -1,80 +0,0 @@ -// 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 Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Cors.Infrastructure; -using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.DependencyInjection; - -namespace CorsWebSite -{ - public class StartupWith21Compat - { - public void ConfigureServices(IServiceCollection services) - { - services.AddMvc() - .SetCompatibilityVersion(CompatibilityVersion.Version_2_1); - services.Configure(options => - { - options.AddPolicy( - "AllowAnySimpleRequest", - builder => - { - builder.AllowAnyOrigin() - .WithMethods("GET", "POST", "HEAD"); - }); - - options.AddPolicy( - "AllowSpecificOrigin", - builder => - { - builder.WithOrigins("http://example.com"); - }); - - options.AddPolicy( - "WithCredentials", - builder => - { - builder.AllowCredentials() - .WithOrigins("http://example.com"); - }); - - options.AddPolicy( - "WithCredentialsAnyOrigin", - builder => - { - builder.AllowCredentials() - .AllowAnyOrigin() - .AllowAnyHeader() - .WithMethods("PUT", "POST") - .WithExposedHeaders("exposed1", "exposed2"); - }); - - options.AddPolicy( - "AllowAll", - builder => - { - builder.AllowCredentials() - .AllowAnyMethod() - .AllowAnyHeader() - .AllowAnyOrigin(); - }); - - options.AddPolicy( - "Allow example.com", - builder => - { - builder.AllowCredentials() - .AllowAnyMethod() - .AllowAnyHeader() - .WithOrigins("http://example.com"); - }); - }); - } - - public void Configure(IApplicationBuilder app) - { - app.UseMvc(); - } - } -} diff --git a/src/Mvc/test/WebSites/CorsWebSite/StartupWithoutEndpointRouting.cs b/src/Mvc/test/WebSites/CorsWebSite/StartupWithoutEndpointRouting.cs new file mode 100644 index 0000000000..308535f451 --- /dev/null +++ b/src/Mvc/test/WebSites/CorsWebSite/StartupWithoutEndpointRouting.cs @@ -0,0 +1,15 @@ +// 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 Microsoft.AspNetCore.Mvc; + +namespace CorsWebSite +{ + public class StartupWithoutEndpointRouting : Startup + { + protected override void ConfigureMvcOptions(MvcOptions options) + { + options.EnableEndpointRouting = false; + } + } +} diff --git a/src/Mvc/test/WebSites/HtmlGenerationWebSite/Startup.cs b/src/Mvc/test/WebSites/HtmlGenerationWebSite/Startup.cs index a1b2a64b26..3cf249f37a 100644 --- a/src/Mvc/test/WebSites/HtmlGenerationWebSite/Startup.cs +++ b/src/Mvc/test/WebSites/HtmlGenerationWebSite/Startup.cs @@ -17,7 +17,7 @@ namespace HtmlGenerationWebSite { // Add MVC services to the services container. Change default FormTagHelper.AntiForgery to false. Usually // null which is interpreted as true unless element includes an action attribute. - services.AddMvc() + services.AddMvc(ConfigureMvcOptions) .InitializeTagHelper((helper, _) => helper.Antiforgery = false) .SetCompatibilityVersion(CompatibilityVersion.Latest); @@ -59,5 +59,9 @@ namespace HtmlGenerationWebSite .UseStartup() .UseKestrel() .UseIISIntegration(); + + protected virtual void ConfigureMvcOptions(MvcOptions options) + { + } } } diff --git a/src/Mvc/test/WebSites/HtmlGenerationWebSite/StartupWith21CompatibilityBehavior.cs b/src/Mvc/test/WebSites/HtmlGenerationWebSite/StartupWith21CompatibilityBehavior.cs deleted file mode 100644 index 5c4fce1ed8..0000000000 --- a/src/Mvc/test/WebSites/HtmlGenerationWebSite/StartupWith21CompatibilityBehavior.cs +++ /dev/null @@ -1,55 +0,0 @@ -// 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.IO; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.TagHelpers; -using Microsoft.Extensions.DependencyInjection; - -namespace HtmlGenerationWebSite -{ - public class StartupWith21CompatibilityBehavior - { - // Set up application services - public void ConfigureServices(IServiceCollection services) - { - // Add MVC services to the services container. Change default FormTagHelper.AntiForgery to false. Usually - // null which is interpreted as true unless element includes an action attribute. - services.AddMvc() - .InitializeTagHelper((helper, _) => helper.Antiforgery = false) - .SetCompatibilityVersion(CompatibilityVersion.Version_2_1); - - services.AddSingleton(typeof(ISignalTokenProviderService<>), typeof(SignalTokenProviderService<>)); - services.AddSingleton(); - } - - public void Configure(IApplicationBuilder app) - { - app.UseStaticFiles(); - app.UseMvc(routes => - { - routes.MapRoute( - name: "areaRoute", - template: "{area:exists}/{controller}/{action}/{id?}", - defaults: new { action = "Index" }); - routes.MapRoute( - name: "productRoute", - template: "Product/{action}", - defaults: new { controller = "Product" }); - routes.MapRoute( - name: "default", - template: "{controller}/{action}/{id?}", - defaults: new { controller = "HtmlGeneration_Home", action = "Index" }); - }); - } - - public static IWebHostBuilder CreateWebHostBuilder(string[] args) => - new WebHostBuilder() - .UseContentRoot(Directory.GetCurrentDirectory()) - .UseStartup() - .UseKestrel() - .UseIISIntegration(); - } -} diff --git a/src/Mvc/test/WebSites/HtmlGenerationWebSite/StartupWithoutEndpointRouting.cs b/src/Mvc/test/WebSites/HtmlGenerationWebSite/StartupWithoutEndpointRouting.cs new file mode 100644 index 0000000000..df0f387a9b --- /dev/null +++ b/src/Mvc/test/WebSites/HtmlGenerationWebSite/StartupWithoutEndpointRouting.cs @@ -0,0 +1,15 @@ +// 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 Microsoft.AspNetCore.Mvc; + +namespace HtmlGenerationWebSite +{ + public class StartupWithoutEndpointRouting : Startup + { + protected override void ConfigureMvcOptions(MvcOptions options) + { + options.EnableEndpointRouting = false; + } + } +} diff --git a/src/Mvc/test/WebSites/RoutingWebSite/Startup.cs b/src/Mvc/test/WebSites/RoutingWebSite/Startup.cs index 1f1be144e4..b113fda2c9 100644 --- a/src/Mvc/test/WebSites/RoutingWebSite/Startup.cs +++ b/src/Mvc/test/WebSites/RoutingWebSite/Startup.cs @@ -21,13 +21,7 @@ namespace RoutingWebSite var pageRouteTransformerConvention = new PageRouteTransformerConvention(new SlugifyParameterTransformer()); services - .AddMvc(options => - { - // Add route token transformer to one controller - options.Conventions.Add(new ControllerRouteTokenTransformerConvention( - typeof(ParameterTransformerController), - new SlugifyParameterTransformer())); - }) + .AddMvc(ConfigureMvcOptions) .AddRazorPagesOptions(options => { options.Conventions.AddPageRoute("/PageRouteTransformer/PageWithConfiguredRoute", "/PageRouteTransformer/NewConventionRoute/{id?}"); @@ -37,11 +31,8 @@ namespace RoutingWebSite }); }) .SetCompatibilityVersion(CompatibilityVersion.Latest); - services - .AddRouting(options => - { - options.ConstraintMap["slugify"] = typeof(SlugifyParameterTransformer); - }); + + ConfigureRoutingServices(services); services.AddScoped(); services.AddSingleton(); @@ -58,11 +49,7 @@ namespace RoutingWebSite constraints: new { controller = "DataTokens" }, dataTokens: new { hasDataTokens = true }); - routes.MapRoute( - "ConventionalTransformerRoute", - "ConventionalTransformerRoute/{controller:slugify}/{action=Index}/{param:slugify?}", - defaults: null, - constraints: new { controller = "ConventionalTransformer" }); + ConfigureConventionalTransformerRoute(routes); routes.MapRoute( "DefaultValuesRoute_OptionalParameter", @@ -83,11 +70,7 @@ namespace RoutingWebSite defaults: new { controller = "Home", action = "Index" }, constraints: new { area = "Travel" }); - routes.MapRoute( - "PageRoute", - "{controller}/{action}/{page}", - defaults: null, - constraints: new { controller = "PageRoute" }); + ConfigurePageRoute(routes); routes.MapRoute( "ActionAsMethod", @@ -104,5 +87,36 @@ namespace RoutingWebSite return c.Response.WriteAsync("Hello from middleware after routing"); })); } + + protected virtual void ConfigureMvcOptions(MvcOptions options) + { + // Add route token transformer to one controller + options.Conventions.Add(new ControllerRouteTokenTransformerConvention( + typeof(ParameterTransformerController), + new SlugifyParameterTransformer())); + } + + protected virtual void ConfigureRoutingServices(IServiceCollection services) + { + services.AddRouting(options => options.ConstraintMap["slugify"] = typeof(SlugifyParameterTransformer)); + } + + protected virtual void ConfigureConventionalTransformerRoute(IRouteBuilder routes) + { + routes.MapRoute( + "ConventionalTransformerRoute", + "ConventionalTransformerRoute/{controller:slugify}/{action=Index}/{param:slugify?}", + defaults: null, + constraints: new { controller = "ConventionalTransformer" }); + } + + protected virtual void ConfigurePageRoute(IRouteBuilder routes) + { + routes.MapRoute( + "PageRoute", + "{controller}/{action}/{page}", + defaults: null, + constraints: new { controller = "PageRoute" }); + } } -} \ No newline at end of file +} diff --git a/src/Mvc/test/WebSites/RoutingWebSite/StartupWith21Compat.cs b/src/Mvc/test/WebSites/RoutingWebSite/StartupWith21Compat.cs deleted file mode 100644 index 9b78b66d32..0000000000 --- a/src/Mvc/test/WebSites/RoutingWebSite/StartupWith21Compat.cs +++ /dev/null @@ -1,99 +0,0 @@ -// 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 Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Abstractions; -using Microsoft.AspNetCore.Mvc.ApplicationModels; -using Microsoft.AspNetCore.Mvc.Infrastructure; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; - -namespace RoutingWebSite -{ - public class StartupWith21Compat - { - // Set up application services - public void ConfigureServices(IServiceCollection services) - { - var pageRouteTransformerConvention = new PageRouteTransformerConvention(new SlugifyParameterTransformer()); - - services - .AddMvc() - .AddRazorPagesOptions(options => - { - options.Conventions.AddPageRoute("/PageRouteTransformer/PageWithConfiguredRoute", "/PageRouteTransformer/NewConventionRoute/{id?}"); - options.Conventions.AddFolderRouteModelConvention("/PageRouteTransformer", model => - { - pageRouteTransformerConvention.Apply(model); - }); - }) - .SetCompatibilityVersion(CompatibilityVersion.Version_2_1); - - services.AddScoped(); - services.AddSingleton(); - - // EndpointRoutingController is not compatible with old routing - // Remove its action to avoid errors - var actionDescriptorProvider = new RemoveControllerActionDescriptorProvider( - new ControllerToRemove - { - ControllerType = typeof(EndpointRoutingController), - Actions = null, // remove all - }, - new ControllerToRemove - { - ControllerType = typeof(PageRouteController), - Actions = new[] { nameof(PageRouteController.AttributeRoute) } - }); - services.TryAddEnumerable(ServiceDescriptor.Singleton(actionDescriptorProvider)); - } - - public void Configure(IApplicationBuilder app) - { - app.UseMvc(routes => - { - routes.MapRoute( - "DataTokensRoute", - "DataTokensRoute/{controller}/{action}", - defaults: null, - constraints: new { controller = "DataTokens" }, - dataTokens: new { hasDataTokens = true }); - - routes.MapRoute( - "DefaultValuesRoute_OptionalParameter", - "DefaultValuesRoute/Optional/{controller=DEFAULTVALUES}/{action=OPTIONALPARAMETER}/{id?}/{**catchAll}", - defaults: null, - constraints: new { controller = "DefaultValues", action = "OptionalParameter" }); - - routes.MapRoute( - "DefaultValuesRoute_DefaultParameter", - "DefaultValuesRoute/Default/{controller=DEFAULTVALUES}/{action=DEFAULTPARAMETER}/{id=17}/{**catchAll}", - defaults: null, - constraints: new { controller = "DefaultValues", action = "DefaultParameter" }); - - routes.MapAreaRoute( - "flightRoute", - "adminRoute", - "{area:exists}/{controller}/{action}", - defaults: new { controller = "Home", action = "Index" }, - constraints: new { area = "Travel" }); - - routes.MapRoute( - "ActionAsMethod", - "{controller}/{action}", - defaults: new { controller = "Home", action = "Index" }); - - routes.MapRoute( - "RouteWithOptionalSegment", - "{controller}/{action}/{path?}"); - }); - - app.Map("/afterrouting", b => b.Run(c => - { - return c.Response.WriteAsync("Hello from middleware after routing"); - })); - } - } -} \ No newline at end of file diff --git a/src/Mvc/test/WebSites/RoutingWebSite/StartupWithoutEndpointRouting.cs b/src/Mvc/test/WebSites/RoutingWebSite/StartupWithoutEndpointRouting.cs new file mode 100644 index 0000000000..083573b622 --- /dev/null +++ b/src/Mvc/test/WebSites/RoutingWebSite/StartupWithoutEndpointRouting.cs @@ -0,0 +1,49 @@ +// 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 Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Abstractions; +using Microsoft.AspNetCore.Routing; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection.Extensions; + +namespace RoutingWebSite +{ + public class StartupWithoutEndpointRouting : Startup + { + // Do not call base implementations of these methods. Those are specific to endpoint routing. + protected override void ConfigureMvcOptions(MvcOptions options) + { + options.EnableEndpointRouting = false; + } + + protected override void ConfigureRoutingServices(IServiceCollection services) + { + // EndpointRoutingController is not compatible with old routing + // Remove its action to avoid errors + var actionDescriptorProvider = new RemoveControllerActionDescriptorProvider( + new ControllerToRemove + { + ControllerType = typeof(EndpointRoutingController), + Actions = null, // remove all + }, + new ControllerToRemove + { + ControllerType = typeof(PageRouteController), + Actions = new[] { nameof(PageRouteController.AttributeRoute) } + }); + + services.TryAddEnumerable(ServiceDescriptor.Singleton(actionDescriptorProvider)); + } + + protected override void ConfigureConventionalTransformerRoute(IRouteBuilder routes) + { + // no-op + } + + protected override void ConfigurePageRoute(IRouteBuilder routes) + { + // no-op + } + } +} diff --git a/src/Mvc/test/WebSites/SecurityWebSite/StartupWith20CompatAndGlobalDenyAnonymousFilter.cs b/src/Mvc/test/WebSites/SecurityWebSite/StartupWith20CompatAndGlobalDenyAnonymousFilter.cs deleted file mode 100644 index b674e76fe0..0000000000 --- a/src/Mvc/test/WebSites/SecurityWebSite/StartupWith20CompatAndGlobalDenyAnonymousFilter.cs +++ /dev/null @@ -1,41 +0,0 @@ -// 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 Microsoft.AspNetCore.Authentication.Cookies; -using Microsoft.AspNetCore.Authorization.Policy; -using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Authorization; -using Microsoft.Extensions.DependencyInjection; - -namespace SecurityWebSite -{ - public class StartupWith20CompatAndGlobalDenyAnonymousFilter - { - public void ConfigureServices(IServiceCollection services) - { - services - .AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) - .AddCookie(options => - { - options.LoginPath = "/Home/Login"; - options.LogoutPath = "/Home/Logout"; - }).AddCookie("Cookie2"); - - services.AddMvc(o => - { - o.Filters.Add(new AuthorizeFilter()); - }) - .SetCompatibilityVersion(CompatibilityVersion.Version_2_0); - - services.AddScoped(); - } - - public void Configure(IApplicationBuilder app) - { - app.UseAuthentication(); - - app.UseMvcWithDefaultRoute(); - } - } -} diff --git a/src/Mvc/test/WebSites/VersioningWebSite/Startup.cs b/src/Mvc/test/WebSites/VersioningWebSite/Startup.cs index 7a94cb2360..4a2b23a9ee 100644 --- a/src/Mvc/test/WebSites/VersioningWebSite/Startup.cs +++ b/src/Mvc/test/WebSites/VersioningWebSite/Startup.cs @@ -13,7 +13,7 @@ namespace VersioningWebSite public void ConfigureServices(IServiceCollection services) { // Add MVC services to the services container - services.AddMvc() + services.AddMvc(ConfigureMvcOptions) .SetCompatibilityVersion(CompatibilityVersion.Latest); services.AddScoped(); @@ -24,5 +24,9 @@ namespace VersioningWebSite { app.UseMvcWithDefaultRoute(); } + + protected virtual void ConfigureMvcOptions(MvcOptions options) + { + } } -} \ No newline at end of file +} diff --git a/src/Mvc/test/WebSites/VersioningWebSite/StartupWith21Compat.cs b/src/Mvc/test/WebSites/VersioningWebSite/StartupWith21Compat.cs deleted file mode 100644 index 44bbc01aa5..0000000000 --- a/src/Mvc/test/WebSites/VersioningWebSite/StartupWith21Compat.cs +++ /dev/null @@ -1,28 +0,0 @@ -// 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 Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.Infrastructure; -using Microsoft.Extensions.DependencyInjection; - -namespace VersioningWebSite -{ - public class StartupWith21Compat - { - public void ConfigureServices(IServiceCollection services) - { - // Add MVC services to the services container - services.AddMvc() - .SetCompatibilityVersion(CompatibilityVersion.Version_2_1); - - services.AddScoped(); - services.AddSingleton(); - } - - public void Configure(IApplicationBuilder app) - { - app.UseMvcWithDefaultRoute(); - } - } -} \ No newline at end of file diff --git a/src/Mvc/test/WebSites/VersioningWebSite/StartupWithoutEndpointRouting.cs b/src/Mvc/test/WebSites/VersioningWebSite/StartupWithoutEndpointRouting.cs new file mode 100644 index 0000000000..0b1668384c --- /dev/null +++ b/src/Mvc/test/WebSites/VersioningWebSite/StartupWithoutEndpointRouting.cs @@ -0,0 +1,15 @@ +// 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 Microsoft.AspNetCore.Mvc; + +namespace VersioningWebSite +{ + public class StartupWithoutEndpointRouting : Startup + { + protected override void ConfigureMvcOptions(MvcOptions options) + { + options.EnableEndpointRouting = false; + } + } +} diff --git a/src/Mvc/test/WebSites/XmlFormattersWebSite/StartupWith21Compat.cs b/src/Mvc/test/WebSites/XmlFormattersWebSite/StartupWith21Compat.cs deleted file mode 100644 index 5b96407d99..0000000000 --- a/src/Mvc/test/WebSites/XmlFormattersWebSite/StartupWith21Compat.cs +++ /dev/null @@ -1,13 +0,0 @@ -// 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 Microsoft.AspNetCore.Mvc; - -namespace XmlFormattersWebSite -{ - public class StartupWith21Compat : Startup - { - public override CompatibilityVersion CompatibilityVersion => CompatibilityVersion.Version_2_1; - } -} - diff --git a/src/SiteExtensions/global.json b/src/SiteExtensions/global.json deleted file mode 100644 index 6df6220662..0000000000 --- a/src/SiteExtensions/global.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "sdk": { - "version": "3.0.100-preview-009750" - }, - "msbuild-sdks": { - "Internal.AspNetCore.Sdk": "3.0.0-build-20181114.5" - } -} diff --git a/src/Templating/src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Startup.cs b/src/Templating/src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Startup.cs index 0eda88fe67..c81aadf1e3 100644 --- a/src/Templating/src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Startup.cs +++ b/src/Templating/src/Microsoft.DotNet.Web.ProjectTemplates/content/RazorPagesWeb-CSharp/Startup.cs @@ -125,10 +125,9 @@ namespace Company.WebApplication1 .RequireAuthenticatedUser() .Build(); options.Filters.Add(new AuthorizeFilter(policy)); - }) - .SetCompatibilityVersion(CompatibilityVersion.Version_2_2); + }); #else - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); + services.AddMvc(); #endif } diff --git a/src/Templating/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/Startup.cs b/src/Templating/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/Startup.cs index a13112913b..a0014d92ae 100644 --- a/src/Templating/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/Startup.cs +++ b/src/Templating/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-CSharp/Startup.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -124,10 +124,9 @@ namespace Company.WebApplication1 .RequireAuthenticatedUser() .Build(); options.Filters.Add(new AuthorizeFilter(policy)); - }) - .SetCompatibilityVersion(CompatibilityVersion.Version_2_2); + }); #else - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); + services.AddMvc(); #endif } diff --git a/src/Templating/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/Startup.fs b/src/Templating/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/Startup.fs index 90b177c8a1..c772867123 100644 --- a/src/Templating/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/Startup.fs +++ b/src/Templating/src/Microsoft.DotNet.Web.ProjectTemplates/content/StarterWeb-FSharp/Startup.fs @@ -1,4 +1,4 @@ -namespace Company.WebApplication1 +namespace Company.WebApplication1 open System open System.Collections.Generic @@ -21,7 +21,7 @@ type Startup private () = // This method gets called by the runtime. Use this method to add services to the container. member this.ConfigureServices(services: IServiceCollection) = // Add framework services. - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2) |> ignore + services.AddMvc() |> ignore // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. member this.Configure(app: IApplicationBuilder, env: IHostingEnvironment) = diff --git a/src/Templating/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/Startup.cs b/src/Templating/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/Startup.cs index 55f223d4e2..ca10c0a668 100644 --- a/src/Templating/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/Startup.cs +++ b/src/Templating/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-CSharp/Startup.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; @@ -43,7 +43,7 @@ namespace Company.WebApplication1 services.AddAuthentication(AzureADB2CDefaults.BearerAuthenticationScheme) .AddAzureADB2CBearer(options => Configuration.Bind("AzureAdB2C", options)); #endif - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); + services.AddMvc(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. diff --git a/src/Templating/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/Startup.fs b/src/Templating/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/Startup.fs index 585cb2e7b4..5a5554c5a2 100644 --- a/src/Templating/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/Startup.fs +++ b/src/Templating/src/Microsoft.DotNet.Web.ProjectTemplates/content/WebApi-FSharp/Startup.fs @@ -21,7 +21,7 @@ type Startup private () = // This method gets called by the runtime. Use this method to add services to the container. member this.ConfigureServices(services: IServiceCollection) = // Add framework services. - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2) |> ignore + services.AddMvc() |> ignore // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. member this.Configure(app: IApplicationBuilder, env: IHostingEnvironment) = diff --git a/src/Templating/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/Startup.cs b/src/Templating/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/Startup.cs index ce4f4cf902..5758f368c1 100644 --- a/src/Templating/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/Startup.cs +++ b/src/Templating/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/Angular-CSharp/Startup.cs @@ -22,7 +22,7 @@ namespace Company.WebApplication1 // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); + services.AddMvc(); // In production, the Angular files will be served from this directory services.AddSpaStaticFiles(configuration => diff --git a/src/Templating/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/React-CSharp/Startup.cs b/src/Templating/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/React-CSharp/Startup.cs index 8f8502913a..3009a15b7f 100644 --- a/src/Templating/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/React-CSharp/Startup.cs +++ b/src/Templating/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/React-CSharp/Startup.cs @@ -22,7 +22,7 @@ namespace Company.WebApplication1 // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); + services.AddMvc(); // In production, the React files will be served from this directory services.AddSpaStaticFiles(configuration => diff --git a/src/Templating/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/Startup.cs b/src/Templating/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/Startup.cs index 8f8502913a..3009a15b7f 100644 --- a/src/Templating/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/Startup.cs +++ b/src/Templating/src/Microsoft.DotNet.Web.Spa.ProjectTemplates/content/ReactRedux-CSharp/Startup.cs @@ -22,7 +22,7 @@ namespace Company.WebApplication1 // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); + services.AddMvc(); // In production, the React files will be served from this directory services.AddSpaStaticFiles(configuration =>