From 0c18367eb4db118ac0b21bd789d0b8c161dc9990 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Wed, 2 Dec 2020 15:54:51 -0800 Subject: [PATCH] Clean up obsolete APIs in MVC --- .../Metadata/ModelMetadataIdentity.cs | 4 +-- src/Mvc/Mvc.Core/src/CompatibilityVersion.cs | 17 +++++++----- .../MvcCoreMvcBuilderExtensions.cs | 3 +++ .../MvcCoreMvcCoreBuilderExtensions.cs | 3 +++ .../MvcCoreServiceCollectionExtensions.cs | 2 -- .../ConfigureCompatibilityOptions.cs | 5 +++- .../Infrastructure/MvcCompatibilityOptions.cs | 6 ++++- ...MvcOptionsConfigureCompatibilityOptions.cs | 27 ------------------- .../Infrastructure/ObjectResultExecutor.cs | 15 ----------- .../PhysicalFileResultExecutor.cs | 1 + .../Validation/ValidationVisitor.cs | 11 +------- src/Mvc/Mvc.Core/src/PublicAPI.Shipped.txt | 3 --- .../MvcCoreServiceCollectionExtensionsTest.cs | 1 - .../ConfigureCompatibilityOptionsTest.cs | 4 ++- .../test/TestStringLocalizer.cs | 6 ----- .../src/Compilation/CompiledViewDescriptor.cs | 4 +-- .../src/Compilation/RazorViewAttribute.cs | 2 +- src/Mvc/Mvc.TagHelpers/src/ImageTagHelper.cs | 4 +-- .../src/PublicAPI.Shipped.txt | 1 - .../src/ViewComponentResultExecutor.cs | 14 ---------- .../MvcServiceCollectionExtensionsTest.cs | 1 - .../benchmarkapps/RazorRendering/Startup.cs | 5 ++-- src/Mvc/samples/MvcSandbox/Startup.cs | 3 +-- .../WebSites/ApiExplorerWebSite/Startup.cs | 3 +-- .../ApplicationModelWebSite/Startup.cs | 3 +-- src/Mvc/test/WebSites/BasicWebSite/Startup.cs | 1 - .../BasicWebSite/StartupRequestLimitSize.cs | 3 +-- .../StartupWhereReadingRequestBodyThrows.cs | 3 +-- ...hCookieTempDataProviderAndCookieConsent.cs | 3 +-- ...artupWithCustomInvalidModelStateFactory.cs | 3 +-- .../BasicWebSite/StartupWithNewtonsoftJson.cs | 1 - .../StartupWithSessionTempDataProvider.cs | 3 +-- .../BasicWebSite/StartupWithSystemTextJson.cs | 3 +-- .../StartupWithoutEndpointRouting.cs | 1 - .../ControllersFromServicesWebSite/Startup.cs | 3 +-- src/Mvc/test/WebSites/CorsWebSite/Startup.cs | 3 +-- .../ErrorPageMiddlewareWebSite/Startup.cs | 3 +-- src/Mvc/test/WebSites/FilesWebSite/Startup.cs | 3 +-- .../test/WebSites/FormatterWebSite/Startup.cs | 3 +-- .../StartupWithComplexParentValidation.cs | 5 ++-- .../StartupWithJsonInputFormatter.cs | 3 +-- .../WebSites/GenericHostWebSite/Startup.cs | 3 +-- .../WebSites/HtmlGenerationWebSite/Startup.cs | 3 +-- .../WebSites/RazorBuildWebSite/Startup.cs | 3 +-- .../WebSites/RazorPagesWebSite/Startup.cs | 3 +-- .../RazorPagesWebSite/StartupWithBasePath.cs | 3 +-- .../StartupWithClientValidationDisabled.cs | 3 +-- .../StartupWithoutEndpointRouting.cs | 3 +-- src/Mvc/test/WebSites/RazorWebSite/Startup.cs | 3 +-- .../RazorWebSite/StartupDataAnnotations.cs | 3 +-- .../test/WebSites/RoutingWebSite/Startup.cs | 3 +-- .../RoutingWebSite/StartupForDynamic.cs | 3 +-- .../StartupForDynamicAndRazorPages.cs | 3 +-- .../RoutingWebSite/StartupForDynamicOrder.cs | 3 +-- .../RoutingWebSite/StartupForFallback.cs | 3 +-- .../RoutingWebSite/StartupForLinkGenerator.cs | 5 ++-- .../StartupRoutingDifferentBranches.cs | 3 +-- .../test/WebSites/SecurityWebSite/Startup.cs | 2 +- .../StartupWithGlobalAuthFilter.cs | 3 +-- ...hGlobalAuthFilterWithoutEndpointRouting.cs | 3 +-- .../StartupWithGlobalDenyAnonymousFilter.cs | 3 +-- ...WithGlobalDenyAnonymousFilterWithUseMvc.cs | 3 +-- .../SecurityWebSite/StartupWithRequireAuth.cs | 2 +- .../SecurityWebSite/StartupWithUseMvc.cs | 5 ++-- .../test/WebSites/SimpleWebSite/Startup.cs | 3 +-- .../WebSites/TagHelpersWebSite/Startup.cs | 3 +-- .../WebSites/VersioningWebSite/Startup.cs | 3 +-- .../WebSites/XmlFormattersWebSite/Startup.cs | 5 +--- .../test/TestContent/Startup.cs.txt | 3 +-- 69 files changed, 86 insertions(+), 194 deletions(-) delete mode 100644 src/Mvc/Mvc.Core/src/Infrastructure/MvcOptionsConfigureCompatibilityOptions.cs diff --git a/src/Mvc/Mvc.Abstractions/src/ModelBinding/Metadata/ModelMetadataIdentity.cs b/src/Mvc/Mvc.Abstractions/src/ModelBinding/Metadata/ModelMetadataIdentity.cs index b170496a5bcc..14395c5fc4fc 100644 --- a/src/Mvc/Mvc.Abstractions/src/ModelBinding/Metadata/ModelMetadataIdentity.cs +++ b/src/Mvc/Mvc.Abstractions/src/ModelBinding/Metadata/ModelMetadataIdentity.cs @@ -48,7 +48,7 @@ public static ModelMetadataIdentity ForType(Type modelType) /// The name of the property. /// The container type of the model property. /// A . - [Obsolete("This API is obsolete and may be removed in a future release.")] + [Obsolete("This API is obsolete and may be removed in a future release. Please use the overload that takes a PropertyInfo object.")] // Remove after .NET 6. public static ModelMetadataIdentity ForProperty( Type modelType, string name, @@ -224,7 +224,7 @@ public bool Equals(ModelMetadataIdentity other) ContainerType == other.ContainerType && ModelType == other.ModelType && Name == other.Name && - ParameterInfo == other.ParameterInfo && + ParameterInfo == other.ParameterInfo && PropertyInfo == other.PropertyInfo && ConstructorInfo == other.ConstructorInfo; } diff --git a/src/Mvc/Mvc.Core/src/CompatibilityVersion.cs b/src/Mvc/Mvc.Core/src/CompatibilityVersion.cs index f8b744da28ea..285379364549 100644 --- a/src/Mvc/Mvc.Core/src/CompatibilityVersion.cs +++ b/src/Mvc/Mvc.Core/src/CompatibilityVersion.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// 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; @@ -37,14 +37,17 @@ namespace Microsoft.AspNetCore.Mvc /// settings to match a particular minor release of ASP.NET Core MVC. /// /// + // Remove after .NET 6. + [Obsolete("This API is obsolete and will be removed in a future version. Consider removing usages.", + DiagnosticId = "ASP5001", + UrlFormat = "https://aka.ms/aspnetcore-warnings/{0}")] public enum CompatibilityVersion { /// /// 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.")] + [Obsolete("This " + nameof(CompatibilityVersion) + " value is obsolete.")] Version_2_0, /// @@ -55,8 +58,7 @@ public enum CompatibilityVersion /// ASP.NET Core MVC 2.1 introduced a compatibility switch for /// MvcJsonOptions.AllowInputFormatterExceptionMessages. This is now a regular property. /// - [Obsolete("This " + nameof(CompatibilityVersion) + " value is obsolete. The recommended alternatives are " + - nameof(Version_3_0) + " or later.")] + [Obsolete("This " + nameof(CompatibilityVersion) + " value is obsolete.")] Version_2_1, /// @@ -72,20 +74,21 @@ public enum CompatibilityVersion /// /// All of the above are now regular properties. /// - [Obsolete("This " + nameof(CompatibilityVersion) + " value is obsolete. The recommended alternatives are " + - nameof(Version_3_0) + " or later.")] + [Obsolete("This " + nameof(CompatibilityVersion) + " value is obsolete.")] 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. /// + [Obsolete("This " + nameof(CompatibilityVersion) + " value is obsolete.")] 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 . /// + [Obsolete("This " + nameof(CompatibilityVersion) + " value is obsolete.")] Latest = int.MaxValue, } } diff --git a/src/Mvc/Mvc.Core/src/DependencyInjection/MvcCoreMvcBuilderExtensions.cs b/src/Mvc/Mvc.Core/src/DependencyInjection/MvcCoreMvcBuilderExtensions.cs index 3d0181a57161..d38baf66b48d 100644 --- a/src/Mvc/Mvc.Core/src/DependencyInjection/MvcCoreMvcBuilderExtensions.cs +++ b/src/Mvc/Mvc.Core/src/DependencyInjection/MvcCoreMvcBuilderExtensions.cs @@ -178,6 +178,9 @@ public static IMvcBuilder AddControllersAsServices(this IMvcBuilder builder) /// The . /// The value to configure. /// The . + [Obsolete("This API is obsolete and will be removed in a future version. Consider removing usages.", + DiagnosticId = "ASP5001", + UrlFormat = "https://aka.ms/aspnetcore-warnings/{0}")] public static IMvcBuilder SetCompatibilityVersion(this IMvcBuilder builder, CompatibilityVersion version) { if (builder == null) diff --git a/src/Mvc/Mvc.Core/src/DependencyInjection/MvcCoreMvcCoreBuilderExtensions.cs b/src/Mvc/Mvc.Core/src/DependencyInjection/MvcCoreMvcCoreBuilderExtensions.cs index 76244cb0aa7f..a55675281b53 100644 --- a/src/Mvc/Mvc.Core/src/DependencyInjection/MvcCoreMvcCoreBuilderExtensions.cs +++ b/src/Mvc/Mvc.Core/src/DependencyInjection/MvcCoreMvcCoreBuilderExtensions.cs @@ -254,6 +254,9 @@ public static IMvcCoreBuilder ConfigureApiBehaviorOptions( /// The . /// The value to configure. /// The . + [Obsolete("This API is obsolete and will be removed in a future version. Consider removing usages.", + DiagnosticId = "ASP5001", + UrlFormat = "https://aka.ms/aspnetcore-warnings/{0}")] public static IMvcCoreBuilder SetCompatibilityVersion(this IMvcCoreBuilder builder, CompatibilityVersion version) { if (builder == null) diff --git a/src/Mvc/Mvc.Core/src/DependencyInjection/MvcCoreServiceCollectionExtensions.cs b/src/Mvc/Mvc.Core/src/DependencyInjection/MvcCoreServiceCollectionExtensions.cs index 95047d08f071..7946b4b882dc 100644 --- a/src/Mvc/Mvc.Core/src/DependencyInjection/MvcCoreServiceCollectionExtensions.cs +++ b/src/Mvc/Mvc.Core/src/DependencyInjection/MvcCoreServiceCollectionExtensions.cs @@ -143,8 +143,6 @@ internal static void AddMvcCoreServices(IServiceCollection services) // services.TryAddEnumerable( ServiceDescriptor.Transient, MvcCoreMvcOptionsSetup>()); - services.TryAddEnumerable( - ServiceDescriptor.Transient, MvcOptionsConfigureCompatibilityOptions>()); services.TryAddEnumerable( ServiceDescriptor.Transient, MvcCoreMvcOptionsSetup>()); services.TryAddEnumerable( diff --git a/src/Mvc/Mvc.Core/src/Infrastructure/ConfigureCompatibilityOptions.cs b/src/Mvc/Mvc.Core/src/Infrastructure/ConfigureCompatibilityOptions.cs index 33009c95de46..844e92190437 100644 --- a/src/Mvc/Mvc.Core/src/Infrastructure/ConfigureCompatibilityOptions.cs +++ b/src/Mvc/Mvc.Core/src/Infrastructure/ConfigureCompatibilityOptions.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// 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; @@ -14,6 +14,9 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure /// by application code. /// /// + [Obsolete("This API is obsolete and will be removed in a future version. Consider removing usages.", + DiagnosticId = "ASP5001", + UrlFormat = "https://aka.ms/aspnetcore-warnings/{0}")] public abstract class ConfigureCompatibilityOptions : IPostConfigureOptions where TOptions : class, IEnumerable { diff --git a/src/Mvc/Mvc.Core/src/Infrastructure/MvcCompatibilityOptions.cs b/src/Mvc/Mvc.Core/src/Infrastructure/MvcCompatibilityOptions.cs index 624bf294c81c..531a9b6a440b 100644 --- a/src/Mvc/Mvc.Core/src/Infrastructure/MvcCompatibilityOptions.cs +++ b/src/Mvc/Mvc.Core/src/Infrastructure/MvcCompatibilityOptions.cs @@ -1,6 +1,7 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// 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.Infrastructure @@ -13,6 +14,9 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure /// calling /// or . /// + [Obsolete("This API is obsolete and will be removed in a future version. Consider removing usages.", + DiagnosticId = "ASP5001", + UrlFormat = "https://aka.ms/aspnetcore-warnings/{0}")] public class MvcCompatibilityOptions { /// diff --git a/src/Mvc/Mvc.Core/src/Infrastructure/MvcOptionsConfigureCompatibilityOptions.cs b/src/Mvc/Mvc.Core/src/Infrastructure/MvcOptionsConfigureCompatibilityOptions.cs deleted file mode 100644 index ec22c47b4a15..000000000000 --- a/src/Mvc/Mvc.Core/src/Infrastructure/MvcOptionsConfigureCompatibilityOptions.cs +++ /dev/null @@ -1,27 +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.Collections.Generic; -using Microsoft.Extensions.Logging; -using Microsoft.Extensions.Options; - -namespace Microsoft.AspNetCore.Mvc.Infrastructure -{ - internal class MvcOptionsConfigureCompatibilityOptions : ConfigureCompatibilityOptions - { - public MvcOptionsConfigureCompatibilityOptions( - ILoggerFactory loggerFactory, - IOptions compatibilityOptions) - : base(loggerFactory, compatibilityOptions) - { - } - - protected override IReadOnlyDictionary DefaultValues - { - get - { - return new Dictionary(); - } - } - } -} diff --git a/src/Mvc/Mvc.Core/src/Infrastructure/ObjectResultExecutor.cs b/src/Mvc/Mvc.Core/src/Infrastructure/ObjectResultExecutor.cs index 869fbb517664..00b62ee5a055 100644 --- a/src/Mvc/Mvc.Core/src/Infrastructure/ObjectResultExecutor.cs +++ b/src/Mvc/Mvc.Core/src/Infrastructure/ObjectResultExecutor.cs @@ -22,21 +22,6 @@ public class ObjectResultExecutor : IActionResultExecutor { private readonly AsyncEnumerableReader _asyncEnumerableReaderFactory; - /// - /// Creates a new . - /// - /// The . - /// The . - /// The . - [Obsolete("This constructor is obsolete and will be removed in a future release.")] - public ObjectResultExecutor( - OutputFormatterSelector formatterSelector, - IHttpResponseStreamWriterFactory writerFactory, - ILoggerFactory loggerFactory) - : this(formatterSelector, writerFactory, loggerFactory, mvcOptions: null) - { - } - /// /// Creates a new . /// diff --git a/src/Mvc/Mvc.Core/src/Infrastructure/PhysicalFileResultExecutor.cs b/src/Mvc/Mvc.Core/src/Infrastructure/PhysicalFileResultExecutor.cs index 5fbf955ed6a8..4445610aa8e2 100644 --- a/src/Mvc/Mvc.Core/src/Infrastructure/PhysicalFileResultExecutor.cs +++ b/src/Mvc/Mvc.Core/src/Infrastructure/PhysicalFileResultExecutor.cs @@ -127,6 +127,7 @@ protected virtual Stream GetFileStream(string path) FileOptions.Asynchronous | FileOptions.SequentialScan); } + /// /// Get the file metadata for a path. /// diff --git a/src/Mvc/Mvc.Core/src/ModelBinding/Validation/ValidationVisitor.cs b/src/Mvc/Mvc.Core/src/ModelBinding/Validation/ValidationVisitor.cs index bfe60d9e3507..76bd22036240 100644 --- a/src/Mvc/Mvc.Core/src/ModelBinding/Validation/ValidationVisitor.cs +++ b/src/Mvc/Mvc.Core/src/ModelBinding/Validation/ValidationVisitor.cs @@ -144,15 +144,6 @@ public int? MaxValidationDepth /// public bool ValidateComplexTypesIfChildValidationFails { get; set; } - /// - /// Gets or sets a value that determines if can short circuit validation when a model - /// does not have any associated validators. - /// - /// The default value is . - /// This property is currently ignored. - [Obsolete("This property is deprecated and is no longer used by the runtime.")] - public bool AllowShortCircuitingValidationWhenNoValidatorsArePresent { get; set; } = true; - /// /// Validates a object. /// @@ -388,7 +379,7 @@ private bool VisitImplementation(ref ModelMetadata metadata, ref string key, obj } /// - /// Validate complex types, this covers everything VisitSimpleType does not i.e. both enumerations and complex types. + /// Validate complex types, this covers everything VisitSimpleType does not i.e. both enumerations and complex types. /// /// The default validation strategy to use. /// if valid, otherwise . diff --git a/src/Mvc/Mvc.Core/src/PublicAPI.Shipped.txt b/src/Mvc/Mvc.Core/src/PublicAPI.Shipped.txt index 9d6013201da9..4876fe82f353 100644 --- a/src/Mvc/Mvc.Core/src/PublicAPI.Shipped.txt +++ b/src/Mvc/Mvc.Core/src/PublicAPI.Shipped.txt @@ -617,8 +617,6 @@ Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidateNeverAttribute Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidateNeverAttribute.ShouldValidateEntry(Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationEntry entry, Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationEntry parentEntry) -> bool Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidateNeverAttribute.ValidateNeverAttribute() -> void Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor -Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.AllowShortCircuitingValidationWhenNoValidatorsArePresent.get -> bool -Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.AllowShortCircuitingValidationWhenNoValidatorsArePresent.set -> void Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.MaxValidationDepth.get -> int? Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.MaxValidationDepth.set -> void Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.StateManager @@ -1402,7 +1400,6 @@ virtual Microsoft.AspNetCore.Mvc.ModelBinding.Validation.ValidationVisitor.Visit ~Microsoft.AspNetCore.Mvc.Infrastructure.ModelStateInvalidFilter.OnActionExecuting(Microsoft.AspNetCore.Mvc.Filters.ActionExecutingContext context) -> void ~Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor.FormatterSelector.get -> Microsoft.AspNetCore.Mvc.Infrastructure.OutputFormatterSelector ~Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor.Logger.get -> Microsoft.Extensions.Logging.ILogger -~Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor.ObjectResultExecutor(Microsoft.AspNetCore.Mvc.Infrastructure.OutputFormatterSelector formatterSelector, Microsoft.AspNetCore.Mvc.Infrastructure.IHttpResponseStreamWriterFactory writerFactory, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory) -> void ~Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor.ObjectResultExecutor(Microsoft.AspNetCore.Mvc.Infrastructure.OutputFormatterSelector formatterSelector, Microsoft.AspNetCore.Mvc.Infrastructure.IHttpResponseStreamWriterFactory writerFactory, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, Microsoft.Extensions.Options.IOptions mvcOptions) -> void ~Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor.WriterFactory.get -> System.Func ~Microsoft.AspNetCore.Mvc.Infrastructure.PhysicalFileResultExecutor.PhysicalFileResultExecutor(Microsoft.Extensions.Logging.ILoggerFactory loggerFactory) -> void diff --git a/src/Mvc/Mvc.Core/test/DependencyInjection/MvcCoreServiceCollectionExtensionsTest.cs b/src/Mvc/Mvc.Core/test/DependencyInjection/MvcCoreServiceCollectionExtensionsTest.cs index bae58287fd3f..f5167822314d 100644 --- a/src/Mvc/Mvc.Core/test/DependencyInjection/MvcCoreServiceCollectionExtensionsTest.cs +++ b/src/Mvc/Mvc.Core/test/DependencyInjection/MvcCoreServiceCollectionExtensionsTest.cs @@ -246,7 +246,6 @@ private Dictionary MultiRegistrationServiceTypes typeof(IPostConfigureOptions), new Type[] { - typeof(MvcOptionsConfigureCompatibilityOptions), typeof(MvcCoreMvcOptionsSetup), } }, diff --git a/src/Mvc/Mvc.Core/test/Infrastructure/ConfigureCompatibilityOptionsTest.cs b/src/Mvc/Mvc.Core/test/Infrastructure/ConfigureCompatibilityOptionsTest.cs index 5c81fbf66de7..21a2bdce9504 100644 --- a/src/Mvc/Mvc.Core/test/Infrastructure/ConfigureCompatibilityOptionsTest.cs +++ b/src/Mvc/Mvc.Core/test/Infrastructure/ConfigureCompatibilityOptionsTest.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// 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.Collections; @@ -8,8 +8,10 @@ using Microsoft.Extensions.Options; using Xunit; +#pragma warning disable ASP5001 // Type or member is obsolete namespace Microsoft.AspNetCore.Mvc.Infrastructure { + [System.Obsolete] public class ConfigureCompatibilityOptionsTest { [Fact] diff --git a/src/Mvc/Mvc.Localization/test/TestStringLocalizer.cs b/src/Mvc/Mvc.Localization/test/TestStringLocalizer.cs index adb4b7ff6494..7b739e6a165c 100644 --- a/src/Mvc/Mvc.Localization/test/TestStringLocalizer.cs +++ b/src/Mvc/Mvc.Localization/test/TestStringLocalizer.cs @@ -67,11 +67,5 @@ public IEnumerable GetAllStrings(bool includeParentCultures) return allStrings; } - - [Obsolete("This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.")] - public IStringLocalizer WithCulture(CultureInfo culture) - { - return new TestStringLocalizer(culture); - } } } diff --git a/src/Mvc/Mvc.Razor/src/Compilation/CompiledViewDescriptor.cs b/src/Mvc/Mvc.Razor/src/Compilation/CompiledViewDescriptor.cs index 6d0213ea30c6..d7b36c1d09fc 100644 --- a/src/Mvc/Mvc.Razor/src/Compilation/CompiledViewDescriptor.cs +++ b/src/Mvc/Mvc.Razor/src/Compilation/CompiledViewDescriptor.cs @@ -78,7 +78,7 @@ public CompiledViewDescriptor(RazorCompiledItem item, RazorViewAttribute attribu /// public string RelativePath { get; set; } -#pragma warning disable CS0618 +#pragma warning disable CS0618 // Type or member is obsolete /// /// Gets or sets the decorating the view. @@ -105,4 +105,4 @@ public CompiledViewDescriptor(RazorCompiledItem item, RazorViewAttribute attribu /// public Type Type => Item?.Type; } -} \ No newline at end of file +} diff --git a/src/Mvc/Mvc.Razor/src/Compilation/RazorViewAttribute.cs b/src/Mvc/Mvc.Razor/src/Compilation/RazorViewAttribute.cs index 1d552a4ff113..d14643bfc601 100644 --- a/src/Mvc/Mvc.Razor/src/Compilation/RazorViewAttribute.cs +++ b/src/Mvc/Mvc.Razor/src/Compilation/RazorViewAttribute.cs @@ -33,4 +33,4 @@ public RazorViewAttribute(string path, Type viewType) /// public Type ViewType { get; } } -} +} \ No newline at end of file diff --git a/src/Mvc/Mvc.TagHelpers/src/ImageTagHelper.cs b/src/Mvc/Mvc.TagHelpers/src/ImageTagHelper.cs index ce3452ed18b7..c85fd14fa68e 100644 --- a/src/Mvc/Mvc.TagHelpers/src/ImageTagHelper.cs +++ b/src/Mvc/Mvc.TagHelpers/src/ImageTagHelper.cs @@ -95,14 +95,14 @@ public ImageTagHelper( /// Gets the for the application. /// This property is obsolete and will be removed in a future version. /// - [Obsolete("This property is obsolete and will be removed in a future version.")] + [Obsolete("This property is obsolete and will be removed in a future version.")] // Remove after .NET 6. protected internal IWebHostEnvironment HostingEnvironment { get; } /// /// Gets the used to store globbed urls. /// This property is obsolete and will be removed in a future version. /// - [Obsolete("This property is obsolete and will be removed in a future version.")] + [Obsolete("This property is obsolete and will be removed in a future version.")] // Remove after .NET 6. protected internal IMemoryCache Cache { get; } internal IFileVersionProvider FileVersionProvider { get; private set; } diff --git a/src/Mvc/Mvc.ViewFeatures/src/PublicAPI.Shipped.txt b/src/Mvc/Mvc.ViewFeatures/src/PublicAPI.Shipped.txt index e371b29c8d18..5f8c2a1c0b8f 100644 --- a/src/Mvc/Mvc.ViewFeatures/src/PublicAPI.Shipped.txt +++ b/src/Mvc/Mvc.ViewFeatures/src/PublicAPI.Shipped.txt @@ -793,7 +793,6 @@ virtual Microsoft.AspNetCore.Mvc.Rendering.MvcForm.GenerateEndForm() -> void ~Microsoft.AspNetCore.Mvc.ViewFeatures.TemplateInfo.HtmlFieldPrefix.set -> void ~Microsoft.AspNetCore.Mvc.ViewFeatures.TemplateInfo.TemplateInfo(Microsoft.AspNetCore.Mvc.ViewFeatures.TemplateInfo original) -> void ~Microsoft.AspNetCore.Mvc.ViewFeatures.TemplateInfo.Visited(Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExplorer modelExplorer) -> bool -~Microsoft.AspNetCore.Mvc.ViewFeatures.ViewComponentResultExecutor.ViewComponentResultExecutor(Microsoft.Extensions.Options.IOptions mvcHelperOptions, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, System.Text.Encodings.Web.HtmlEncoder htmlEncoder, Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider modelMetadataProvider, Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory tempDataDictionaryFactory) -> void ~Microsoft.AspNetCore.Mvc.ViewFeatures.ViewComponentResultExecutor.ViewComponentResultExecutor(Microsoft.Extensions.Options.IOptions mvcHelperOptions, Microsoft.Extensions.Logging.ILoggerFactory loggerFactory, System.Text.Encodings.Web.HtmlEncoder htmlEncoder, Microsoft.AspNetCore.Mvc.ModelBinding.IModelMetadataProvider modelMetadataProvider, Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory tempDataDictionaryFactory, Microsoft.AspNetCore.Mvc.Infrastructure.IHttpResponseStreamWriterFactory writerFactory) -> void ~Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.Add(System.Collections.Generic.KeyValuePair item) -> void ~Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.Add(string key, object value) -> void diff --git a/src/Mvc/Mvc.ViewFeatures/src/ViewComponentResultExecutor.cs b/src/Mvc/Mvc.ViewFeatures/src/ViewComponentResultExecutor.cs index 2a74e51d4539..0dc7618a593c 100644 --- a/src/Mvc/Mvc.ViewFeatures/src/ViewComponentResultExecutor.cs +++ b/src/Mvc/Mvc.ViewFeatures/src/ViewComponentResultExecutor.cs @@ -31,20 +31,6 @@ public class ViewComponentResultExecutor : IActionResultExecutor - /// This constructor is obsolete and will be removed in a future version. - /// - [Obsolete("This constructor is obsolete and will be removed in a future version.")] - public ViewComponentResultExecutor( - IOptions mvcHelperOptions, - ILoggerFactory loggerFactory, - HtmlEncoder htmlEncoder, - IModelMetadataProvider modelMetadataProvider, - ITempDataDictionaryFactory tempDataDictionaryFactory) - : this(mvcHelperOptions, loggerFactory, htmlEncoder, modelMetadataProvider, tempDataDictionaryFactory, null) - { - } - /// /// Initialize a new instance of /// diff --git a/src/Mvc/Mvc/test/MvcServiceCollectionExtensionsTest.cs b/src/Mvc/Mvc/test/MvcServiceCollectionExtensionsTest.cs index fa7309d6ea87..75e63b64c54c 100644 --- a/src/Mvc/Mvc/test/MvcServiceCollectionExtensionsTest.cs +++ b/src/Mvc/Mvc/test/MvcServiceCollectionExtensionsTest.cs @@ -499,7 +499,6 @@ private Dictionary MultiRegistrationServiceTypes typeof(IPostConfigureOptions), new[] { - typeof(MvcOptionsConfigureCompatibilityOptions), typeof(MvcCoreMvcOptionsSetup), } }, diff --git a/src/Mvc/benchmarkapps/RazorRendering/Startup.cs b/src/Mvc/benchmarkapps/RazorRendering/Startup.cs index 2eb0abb1c1b2..c332e9f2a8be 100644 --- a/src/Mvc/benchmarkapps/RazorRendering/Startup.cs +++ b/src/Mvc/benchmarkapps/RazorRendering/Startup.cs @@ -16,8 +16,7 @@ public void ConfigureServices(IServiceCollection services) { services.AddScoped>(_ => DataA); services.AddScoped>(_ => DataB); - services.AddMvc() - .SetCompatibilityVersion(CompatibilityVersion.Latest); + services.AddMvc(); } public void Configure(IApplicationBuilder app, IHostingEnvironment env) @@ -81,4 +80,4 @@ public static IWebHostBuilder CreateWebHostBuilder(string[] args) .UseContentRoot(Directory.GetCurrentDirectory()) .UseStartup(); } -} \ No newline at end of file +} diff --git a/src/Mvc/samples/MvcSandbox/Startup.cs b/src/Mvc/samples/MvcSandbox/Startup.cs index dc7af517529c..31bafaf505ac 100644 --- a/src/Mvc/samples/MvcSandbox/Startup.cs +++ b/src/Mvc/samples/MvcSandbox/Startup.cs @@ -26,8 +26,7 @@ public void ConfigureServices(IServiceCollection services) options.ConstraintMap["slugify"] = typeof(SlugifyParameterTransformer); }); services.AddServerSideBlazor(); - services.AddMvc() - .SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Latest); + services.AddMvc(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. diff --git a/src/Mvc/test/WebSites/ApiExplorerWebSite/Startup.cs b/src/Mvc/test/WebSites/ApiExplorerWebSite/Startup.cs index e810a1e66696..c7cb1554f26a 100644 --- a/src/Mvc/test/WebSites/ApiExplorerWebSite/Startup.cs +++ b/src/Mvc/test/WebSites/ApiExplorerWebSite/Startup.cs @@ -36,8 +36,7 @@ public void ConfigureServices(IServiceCollection services) options.OutputFormatters.Clear(); options.OutputFormatters.Add(new XmlDataContractSerializerOutputFormatter()); }) - .AddNewtonsoftJson() - .SetCompatibilityVersion(CompatibilityVersion.Latest); + .AddNewtonsoftJson(); services.AddSingleton(); services.AddSingleton(); diff --git a/src/Mvc/test/WebSites/ApplicationModelWebSite/Startup.cs b/src/Mvc/test/WebSites/ApplicationModelWebSite/Startup.cs index 3c8dab4407ff..be51dac7130b 100644 --- a/src/Mvc/test/WebSites/ApplicationModelWebSite/Startup.cs +++ b/src/Mvc/test/WebSites/ApplicationModelWebSite/Startup.cs @@ -21,8 +21,7 @@ public void ConfigureServices(IServiceCollection services) options.Conventions.Add(new FromHeaderConvention()); options.Conventions.Add(new MultipleAreasControllerConvention()); options.Conventions.Add(new CloneActionConvention()); - }) - .SetCompatibilityVersion(CompatibilityVersion.Latest); + }); services.AddRazorPages(); } diff --git a/src/Mvc/test/WebSites/BasicWebSite/Startup.cs b/src/Mvc/test/WebSites/BasicWebSite/Startup.cs index 3d93826f2c91..ad0aa1bbdd75 100644 --- a/src/Mvc/test/WebSites/BasicWebSite/Startup.cs +++ b/src/Mvc/test/WebSites/BasicWebSite/Startup.cs @@ -14,7 +14,6 @@ public class Startup public void ConfigureServices(IServiceCollection services) { services.AddMvc() - .SetCompatibilityVersion(CompatibilityVersion.Latest) .AddNewtonsoftJson() .AddXmlDataContractSerializerFormatters(); diff --git a/src/Mvc/test/WebSites/BasicWebSite/StartupRequestLimitSize.cs b/src/Mvc/test/WebSites/BasicWebSite/StartupRequestLimitSize.cs index ed7524fa4da6..f07cd83b6a26 100644 --- a/src/Mvc/test/WebSites/BasicWebSite/StartupRequestLimitSize.cs +++ b/src/Mvc/test/WebSites/BasicWebSite/StartupRequestLimitSize.cs @@ -17,8 +17,7 @@ public class StartupRequestLimitSize public void ConfigureServices(IServiceCollection services) { services.AddMvc() - .AddNewtonsoftJson() - .SetCompatibilityVersion(CompatibilityVersion.Latest); + .AddNewtonsoftJson(); services.ConfigureBaseWebSiteAuthPolicies(); } diff --git a/src/Mvc/test/WebSites/BasicWebSite/StartupWhereReadingRequestBodyThrows.cs b/src/Mvc/test/WebSites/BasicWebSite/StartupWhereReadingRequestBodyThrows.cs index 25b3855d2e7d..7e0b0c6637e7 100644 --- a/src/Mvc/test/WebSites/BasicWebSite/StartupWhereReadingRequestBodyThrows.cs +++ b/src/Mvc/test/WebSites/BasicWebSite/StartupWhereReadingRequestBodyThrows.cs @@ -20,8 +20,7 @@ public class StartupWhereReadingRequestBodyThrows // Set up application services public void ConfigureServices(IServiceCollection services) { - services.AddControllersWithViews() - .SetCompatibilityVersion(CompatibilityVersion.Latest); + services.AddControllersWithViews(); } public void Configure(IApplicationBuilder app) diff --git a/src/Mvc/test/WebSites/BasicWebSite/StartupWithCookieTempDataProviderAndCookieConsent.cs b/src/Mvc/test/WebSites/BasicWebSite/StartupWithCookieTempDataProviderAndCookieConsent.cs index 7083bd21dc9a..a80d41d673ff 100644 --- a/src/Mvc/test/WebSites/BasicWebSite/StartupWithCookieTempDataProviderAndCookieConsent.cs +++ b/src/Mvc/test/WebSites/BasicWebSite/StartupWithCookieTempDataProviderAndCookieConsent.cs @@ -12,8 +12,7 @@ public class StartupWithCookieTempDataProviderAndCookieConsent public void ConfigureServices(IServiceCollection services) { services.AddMvc() - .AddNewtonsoftJson() - .SetCompatibilityVersion(CompatibilityVersion.Latest); + .AddNewtonsoftJson(); services.Configure(o => { diff --git a/src/Mvc/test/WebSites/BasicWebSite/StartupWithCustomInvalidModelStateFactory.cs b/src/Mvc/test/WebSites/BasicWebSite/StartupWithCustomInvalidModelStateFactory.cs index 66feb4d7cf6d..90ef21416e8d 100644 --- a/src/Mvc/test/WebSites/BasicWebSite/StartupWithCustomInvalidModelStateFactory.cs +++ b/src/Mvc/test/WebSites/BasicWebSite/StartupWithCustomInvalidModelStateFactory.cs @@ -19,8 +19,7 @@ public void ConfigureServices(IServiceCollection services) services .AddMvc() - .AddNewtonsoftJson() - .SetCompatibilityVersion(CompatibilityVersion.Latest); + .AddNewtonsoftJson(); services.Configure(options => { diff --git a/src/Mvc/test/WebSites/BasicWebSite/StartupWithNewtonsoftJson.cs b/src/Mvc/test/WebSites/BasicWebSite/StartupWithNewtonsoftJson.cs index b4c63a52a718..eee75bb925a5 100644 --- a/src/Mvc/test/WebSites/BasicWebSite/StartupWithNewtonsoftJson.cs +++ b/src/Mvc/test/WebSites/BasicWebSite/StartupWithNewtonsoftJson.cs @@ -13,7 +13,6 @@ public void ConfigureServices(IServiceCollection services) { services .AddMvc() - .SetCompatibilityVersion(CompatibilityVersion.Latest) .AddNewtonsoftJson(); } diff --git a/src/Mvc/test/WebSites/BasicWebSite/StartupWithSessionTempDataProvider.cs b/src/Mvc/test/WebSites/BasicWebSite/StartupWithSessionTempDataProvider.cs index 744a3fea0b15..ab9192a61f34 100644 --- a/src/Mvc/test/WebSites/BasicWebSite/StartupWithSessionTempDataProvider.cs +++ b/src/Mvc/test/WebSites/BasicWebSite/StartupWithSessionTempDataProvider.cs @@ -14,8 +14,7 @@ public void ConfigureServices(IServiceCollection services) // CookieTempDataProvider is the default ITempDataProvider, so we must override it with session. services .AddMvc() - .AddSessionStateTempDataProvider() - .SetCompatibilityVersion(CompatibilityVersion.Latest); + .AddSessionStateTempDataProvider(); services.AddSession(); services.ConfigureBaseWebSiteAuthPolicies(); diff --git a/src/Mvc/test/WebSites/BasicWebSite/StartupWithSystemTextJson.cs b/src/Mvc/test/WebSites/BasicWebSite/StartupWithSystemTextJson.cs index f5e0c308e5b4..04601e20a0e8 100644 --- a/src/Mvc/test/WebSites/BasicWebSite/StartupWithSystemTextJson.cs +++ b/src/Mvc/test/WebSites/BasicWebSite/StartupWithSystemTextJson.cs @@ -12,8 +12,7 @@ public class StartupWithSystemTextJson public void ConfigureServices(IServiceCollection services) { services - .AddMvc() - .SetCompatibilityVersion(CompatibilityVersion.Latest); + .AddMvc(); services.AddSingleton(); } diff --git a/src/Mvc/test/WebSites/BasicWebSite/StartupWithoutEndpointRouting.cs b/src/Mvc/test/WebSites/BasicWebSite/StartupWithoutEndpointRouting.cs index 16828aacd3bc..3a979735267a 100644 --- a/src/Mvc/test/WebSites/BasicWebSite/StartupWithoutEndpointRouting.cs +++ b/src/Mvc/test/WebSites/BasicWebSite/StartupWithoutEndpointRouting.cs @@ -36,7 +36,6 @@ public void ConfigureServices(IServiceCollection services) options.EnableEndpointRouting = false; }) - .SetCompatibilityVersion(CompatibilityVersion.Latest) .AddNewtonsoftJson() .AddXmlDataContractSerializerFormatters(); diff --git a/src/Mvc/test/WebSites/ControllersFromServicesWebSite/Startup.cs b/src/Mvc/test/WebSites/ControllersFromServicesWebSite/Startup.cs index 910cfd69aa96..f5e55e015e1f 100644 --- a/src/Mvc/test/WebSites/ControllersFromServicesWebSite/Startup.cs +++ b/src/Mvc/test/WebSites/ControllersFromServicesWebSite/Startup.cs @@ -42,8 +42,7 @@ public void ConfigureServices(IServiceCollection services) }) .AddControllersAsServices() .AddViewComponentsAsServices() - .AddTagHelpersAsServices() - .SetCompatibilityVersion(CompatibilityVersion.Latest); + .AddTagHelpersAsServices(); services.AddTransient(); services.AddTransient(); diff --git a/src/Mvc/test/WebSites/CorsWebSite/Startup.cs b/src/Mvc/test/WebSites/CorsWebSite/Startup.cs index 5aa8fc7f63ce..de821da8621a 100644 --- a/src/Mvc/test/WebSites/CorsWebSite/Startup.cs +++ b/src/Mvc/test/WebSites/CorsWebSite/Startup.cs @@ -12,8 +12,7 @@ public class Startup { public void ConfigureServices(IServiceCollection services) { - services.AddControllers(ConfigureMvcOptions) - .SetCompatibilityVersion(CompatibilityVersion.Latest); + services.AddControllers(ConfigureMvcOptions); services.Configure(options => { options.AddPolicy( diff --git a/src/Mvc/test/WebSites/ErrorPageMiddlewareWebSite/Startup.cs b/src/Mvc/test/WebSites/ErrorPageMiddlewareWebSite/Startup.cs index d8ba0f40d39d..39143c0bf3c2 100644 --- a/src/Mvc/test/WebSites/ErrorPageMiddlewareWebSite/Startup.cs +++ b/src/Mvc/test/WebSites/ErrorPageMiddlewareWebSite/Startup.cs @@ -15,8 +15,7 @@ public class Startup public void ConfigureServices(IServiceCollection services) { services.AddControllersWithViews() - .AddRazorRuntimeCompilation() - .SetCompatibilityVersion(CompatibilityVersion.Latest); + .AddRazorRuntimeCompilation(); } public void Configure(IApplicationBuilder app) diff --git a/src/Mvc/test/WebSites/FilesWebSite/Startup.cs b/src/Mvc/test/WebSites/FilesWebSite/Startup.cs index 518b69212fe8..7b7cb6aa91ae 100644 --- a/src/Mvc/test/WebSites/FilesWebSite/Startup.cs +++ b/src/Mvc/test/WebSites/FilesWebSite/Startup.cs @@ -15,8 +15,7 @@ public class Startup public void ConfigureServices(IServiceCollection services) { services.AddControllers() - .AddNewtonsoftJson() - .SetCompatibilityVersion(CompatibilityVersion.Latest); + .AddNewtonsoftJson(); } public void Configure(IApplicationBuilder app) diff --git a/src/Mvc/test/WebSites/FormatterWebSite/Startup.cs b/src/Mvc/test/WebSites/FormatterWebSite/Startup.cs index ac3d04966f8f..b25ebaeffd61 100644 --- a/src/Mvc/test/WebSites/FormatterWebSite/Startup.cs +++ b/src/Mvc/test/WebSites/FormatterWebSite/Startup.cs @@ -20,8 +20,7 @@ public void ConfigureServices(IServiceCollection services) options.InputFormatters.Add(new StringInputFormatter()); }) .AddNewtonsoftJson(options => options.SerializerSettings.Converters.Insert(0, new IModelConverter())) - .AddXmlDataContractSerializerFormatters() - .SetCompatibilityVersion(CompatibilityVersion.Latest); + .AddXmlDataContractSerializerFormatters(); } public void Configure(IApplicationBuilder app) diff --git a/src/Mvc/test/WebSites/FormatterWebSite/StartupWithComplexParentValidation.cs b/src/Mvc/test/WebSites/FormatterWebSite/StartupWithComplexParentValidation.cs index 44d066a4aab9..8def682f3c63 100644 --- a/src/Mvc/test/WebSites/FormatterWebSite/StartupWithComplexParentValidation.cs +++ b/src/Mvc/test/WebSites/FormatterWebSite/StartupWithComplexParentValidation.cs @@ -13,8 +13,7 @@ public void ConfigureServices(IServiceCollection services) { services .AddControllers(options => options.ValidateComplexTypesIfChildValidationFails = true) - .AddNewtonsoftJson(options => options.SerializerSettings.Converters.Insert(0, new IModelConverter())) - .SetCompatibilityVersion(CompatibilityVersion.Latest); + .AddNewtonsoftJson(options => options.SerializerSettings.Converters.Insert(0, new IModelConverter())); } public void Configure(IApplicationBuilder app) @@ -26,4 +25,4 @@ public void Configure(IApplicationBuilder app) }); } } -} \ No newline at end of file +} diff --git a/src/Mvc/test/WebSites/FormatterWebSite/StartupWithJsonInputFormatter.cs b/src/Mvc/test/WebSites/FormatterWebSite/StartupWithJsonInputFormatter.cs index 3966fb6ba4c1..546b6c065edf 100644 --- a/src/Mvc/test/WebSites/FormatterWebSite/StartupWithJsonInputFormatter.cs +++ b/src/Mvc/test/WebSites/FormatterWebSite/StartupWithJsonInputFormatter.cs @@ -17,8 +17,7 @@ public void ConfigureServices(IServiceCollection services) options.ModelMetadataDetailsProviders.Add(new SuppressChildValidationMetadataProvider(typeof(Developer))); options.ModelMetadataDetailsProviders.Add(new SuppressChildValidationMetadataProvider(typeof(Supplier))); }) - .AddXmlDataContractSerializerFormatters() - .SetCompatibilityVersion(CompatibilityVersion.Latest); + .AddXmlDataContractSerializerFormatters(); } public void Configure(IApplicationBuilder app) diff --git a/src/Mvc/test/WebSites/GenericHostWebSite/Startup.cs b/src/Mvc/test/WebSites/GenericHostWebSite/Startup.cs index 75362be7ec94..65c51572dfc4 100644 --- a/src/Mvc/test/WebSites/GenericHostWebSite/Startup.cs +++ b/src/Mvc/test/WebSites/GenericHostWebSite/Startup.cs @@ -20,8 +20,7 @@ public void ConfigureServices(IServiceCollection services) { // Remove when all URL generation tests are passing - https://github.com/aspnet/Routing/issues/590 options.EnableEndpointRouting = false; - }) - .SetCompatibilityVersion(CompatibilityVersion.Latest); + }); services.AddLogging(); services.AddHttpContextAccessor(); diff --git a/src/Mvc/test/WebSites/HtmlGenerationWebSite/Startup.cs b/src/Mvc/test/WebSites/HtmlGenerationWebSite/Startup.cs index bf34e47faaa6..7d0b7258dc94 100644 --- a/src/Mvc/test/WebSites/HtmlGenerationWebSite/Startup.cs +++ b/src/Mvc/test/WebSites/HtmlGenerationWebSite/Startup.cs @@ -18,8 +18,7 @@ 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(ConfigureMvcOptions) - .InitializeTagHelper((helper, _) => helper.Antiforgery = false) - .SetCompatibilityVersion(CompatibilityVersion.Latest); + .InitializeTagHelper((helper, _) => helper.Antiforgery = false); services.AddSingleton(typeof(ISignalTokenProviderService<>), typeof(SignalTokenProviderService<>)); services.AddSingleton(); diff --git a/src/Mvc/test/WebSites/RazorBuildWebSite/Startup.cs b/src/Mvc/test/WebSites/RazorBuildWebSite/Startup.cs index 0db8a20c74b2..24b332bdf6df 100644 --- a/src/Mvc/test/WebSites/RazorBuildWebSite/Startup.cs +++ b/src/Mvc/test/WebSites/RazorBuildWebSite/Startup.cs @@ -17,8 +17,7 @@ public void ConfigureServices(IServiceCollection services) services.AddSingleton(fileProvider); services.AddMvc() - .AddRazorRuntimeCompilation(options => options.FileProviders.Add(fileProvider)) - .SetCompatibilityVersion(CompatibilityVersion.Latest); + .AddRazorRuntimeCompilation(options => options.FileProviders.Add(fileProvider)); } public void Configure(IApplicationBuilder app) diff --git a/src/Mvc/test/WebSites/RazorPagesWebSite/Startup.cs b/src/Mvc/test/WebSites/RazorPagesWebSite/Startup.cs index e75ac2f1abca..d29e1cabbd7a 100644 --- a/src/Mvc/test/WebSites/RazorPagesWebSite/Startup.cs +++ b/src/Mvc/test/WebSites/RazorPagesWebSite/Startup.cs @@ -18,8 +18,7 @@ public void ConfigureServices(IServiceCollection services) services.AddRazorPages(options => { options.Conventions.AuthorizeFolder("/Admin"); - }) - .SetCompatibilityVersion(CompatibilityVersion.Latest); + }); } public void Configure(IApplicationBuilder app) diff --git a/src/Mvc/test/WebSites/RazorPagesWebSite/StartupWithBasePath.cs b/src/Mvc/test/WebSites/RazorPagesWebSite/StartupWithBasePath.cs index 97f11d6235ff..53ac7e22ca6a 100644 --- a/src/Mvc/test/WebSites/RazorPagesWebSite/StartupWithBasePath.cs +++ b/src/Mvc/test/WebSites/RazorPagesWebSite/StartupWithBasePath.cs @@ -32,8 +32,7 @@ public void ConfigureServices(IServiceCollection services) options.Conventions.AuthorizeAreaFolder("Accounts", "/RequiresAuth"); options.Conventions.AllowAnonymousToAreaPage("Accounts", "/RequiresAuth/AllowAnonymous"); options.Conventions.Add(new CustomModelTypeConvention()); - }) - .SetCompatibilityVersion(CompatibilityVersion.Latest); + }); } public void Configure(IApplicationBuilder app) diff --git a/src/Mvc/test/WebSites/RazorPagesWebSite/StartupWithClientValidationDisabled.cs b/src/Mvc/test/WebSites/RazorPagesWebSite/StartupWithClientValidationDisabled.cs index 68cb0f6e308a..e7251a74cb3d 100644 --- a/src/Mvc/test/WebSites/RazorPagesWebSite/StartupWithClientValidationDisabled.cs +++ b/src/Mvc/test/WebSites/RazorPagesWebSite/StartupWithClientValidationDisabled.cs @@ -18,8 +18,7 @@ public void ConfigureServices(IServiceCollection services) services.AddRazorPages(options => { options.Conventions.AuthorizeFolder("/Admin"); - }) - .SetCompatibilityVersion(CompatibilityVersion.Latest); + }); services.Configure(o => o.HtmlHelperOptions.ClientValidationEnabled = false); } diff --git a/src/Mvc/test/WebSites/RazorPagesWebSite/StartupWithoutEndpointRouting.cs b/src/Mvc/test/WebSites/RazorPagesWebSite/StartupWithoutEndpointRouting.cs index a091d0a86d39..2993998ca3a8 100644 --- a/src/Mvc/test/WebSites/RazorPagesWebSite/StartupWithoutEndpointRouting.cs +++ b/src/Mvc/test/WebSites/RazorPagesWebSite/StartupWithoutEndpointRouting.cs @@ -26,8 +26,7 @@ public void ConfigureServices(IServiceCollection services) options.Conventions.AddPageRoute("/Pages/NotTheRoot", string.Empty); options.Conventions.Add(new CustomModelTypeConvention()); }) - .WithRazorPagesAtContentRoot() - .SetCompatibilityVersion(CompatibilityVersion.Latest); + .WithRazorPagesAtContentRoot(); } public void Configure(IApplicationBuilder app) diff --git a/src/Mvc/test/WebSites/RazorWebSite/Startup.cs b/src/Mvc/test/WebSites/RazorWebSite/Startup.cs index 915e8607de1d..b4dde6201805 100644 --- a/src/Mvc/test/WebSites/RazorWebSite/Startup.cs +++ b/src/Mvc/test/WebSites/RazorWebSite/Startup.cs @@ -34,8 +34,7 @@ public void ConfigureServices(IServiceCollection services) options.HtmlHelperOptions.ValidationMessageElement = "validationMessageElement"; options.HtmlHelperOptions.ValidationSummaryMessageElement = "validationSummaryElement"; }) - .AddMvcLocalization(LanguageViewLocationExpanderFormat.SubFolder) - .SetCompatibilityVersion(CompatibilityVersion.Latest); + .AddMvcLocalization(LanguageViewLocationExpanderFormat.SubFolder); services.AddTransient(); services.AddTransient(); diff --git a/src/Mvc/test/WebSites/RazorWebSite/StartupDataAnnotations.cs b/src/Mvc/test/WebSites/RazorWebSite/StartupDataAnnotations.cs index 63f063aef876..8344a71ee775 100644 --- a/src/Mvc/test/WebSites/RazorWebSite/StartupDataAnnotations.cs +++ b/src/Mvc/test/WebSites/RazorWebSite/StartupDataAnnotations.cs @@ -24,8 +24,7 @@ public void ConfigureServices(IServiceCollection services) { options.DataAnnotationLocalizerProvider = (modelType, stringLocalizerFactory) => stringLocalizerFactory.Create(typeof(SingleType)); - }) - .SetCompatibilityVersion(CompatibilityVersion.Latest); + }); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. diff --git a/src/Mvc/test/WebSites/RoutingWebSite/Startup.cs b/src/Mvc/test/WebSites/RoutingWebSite/Startup.cs index c44d472f7ca0..ba84c82b03fc 100644 --- a/src/Mvc/test/WebSites/RoutingWebSite/Startup.cs +++ b/src/Mvc/test/WebSites/RoutingWebSite/Startup.cs @@ -27,8 +27,7 @@ public void ConfigureServices(IServiceCollection services) { pageRouteTransformerConvention.Apply(model); }); - }) - .SetCompatibilityVersion(CompatibilityVersion.Latest); + }); ConfigureRoutingServices(services); diff --git a/src/Mvc/test/WebSites/RoutingWebSite/StartupForDynamic.cs b/src/Mvc/test/WebSites/RoutingWebSite/StartupForDynamic.cs index 92d552205161..8d5215f7948c 100644 --- a/src/Mvc/test/WebSites/RoutingWebSite/StartupForDynamic.cs +++ b/src/Mvc/test/WebSites/RoutingWebSite/StartupForDynamic.cs @@ -21,8 +21,7 @@ public void ConfigureServices(IServiceCollection services) { services .AddMvc() - .AddNewtonsoftJson() - .SetCompatibilityVersion(CompatibilityVersion.Latest); + .AddNewtonsoftJson(); services.AddTransient(); services.AddScoped(); diff --git a/src/Mvc/test/WebSites/RoutingWebSite/StartupForDynamicAndRazorPages.cs b/src/Mvc/test/WebSites/RoutingWebSite/StartupForDynamicAndRazorPages.cs index 1048a972ea9a..1dbe60010df1 100644 --- a/src/Mvc/test/WebSites/RoutingWebSite/StartupForDynamicAndRazorPages.cs +++ b/src/Mvc/test/WebSites/RoutingWebSite/StartupForDynamicAndRazorPages.cs @@ -17,8 +17,7 @@ public class StartupForDynamicAndRazorPages public void ConfigureServices(IServiceCollection services) { services - .AddMvc() - .SetCompatibilityVersion(CompatibilityVersion.Latest); + .AddMvc(); services.AddTransient(); diff --git a/src/Mvc/test/WebSites/RoutingWebSite/StartupForDynamicOrder.cs b/src/Mvc/test/WebSites/RoutingWebSite/StartupForDynamicOrder.cs index 2d3c96c57986..fc180b8bc9d9 100644 --- a/src/Mvc/test/WebSites/RoutingWebSite/StartupForDynamicOrder.cs +++ b/src/Mvc/test/WebSites/RoutingWebSite/StartupForDynamicOrder.cs @@ -38,8 +38,7 @@ public void ConfigureServices(IServiceCollection services) { services .AddMvc() - .AddNewtonsoftJson() - .SetCompatibilityVersion(CompatibilityVersion.Latest); + .AddNewtonsoftJson(); services.AddTransient(); services.AddScoped(); diff --git a/src/Mvc/test/WebSites/RoutingWebSite/StartupForFallback.cs b/src/Mvc/test/WebSites/RoutingWebSite/StartupForFallback.cs index ed67647bb3f4..613954986612 100644 --- a/src/Mvc/test/WebSites/RoutingWebSite/StartupForFallback.cs +++ b/src/Mvc/test/WebSites/RoutingWebSite/StartupForFallback.cs @@ -16,8 +16,7 @@ public void ConfigureServices(IServiceCollection services) { services .AddMvc() - .AddNewtonsoftJson() - .SetCompatibilityVersion(CompatibilityVersion.Latest); + .AddNewtonsoftJson(); // Used by some controllers defined in this project. services.Configure(options => options.ConstraintMap["slugify"] = typeof(SlugifyParameterTransformer)); diff --git a/src/Mvc/test/WebSites/RoutingWebSite/StartupForLinkGenerator.cs b/src/Mvc/test/WebSites/RoutingWebSite/StartupForLinkGenerator.cs index 5b6504c3515d..b77dc5cd2b42 100644 --- a/src/Mvc/test/WebSites/RoutingWebSite/StartupForLinkGenerator.cs +++ b/src/Mvc/test/WebSites/RoutingWebSite/StartupForLinkGenerator.cs @@ -25,8 +25,7 @@ public void ConfigureServices(IServiceCollection services) { pageRouteTransformerConvention.Apply(model); }); - }) - .SetCompatibilityVersion(CompatibilityVersion.Latest); + }); services .AddRouting(options => { @@ -49,4 +48,4 @@ public void Configure(IApplicationBuilder app) }); } } -} \ No newline at end of file +} diff --git a/src/Mvc/test/WebSites/RoutingWebSite/StartupRoutingDifferentBranches.cs b/src/Mvc/test/WebSites/RoutingWebSite/StartupRoutingDifferentBranches.cs index d118d7d12a0b..cf1658fa098c 100644 --- a/src/Mvc/test/WebSites/RoutingWebSite/StartupRoutingDifferentBranches.cs +++ b/src/Mvc/test/WebSites/RoutingWebSite/StartupRoutingDifferentBranches.cs @@ -30,8 +30,7 @@ public void ConfigureServices(IServiceCollection services) { pageRouteTransformerConvention.Apply(model); }); - }) - .SetCompatibilityVersion(CompatibilityVersion.Latest); + }); ConfigureRoutingServices(services); diff --git a/src/Mvc/test/WebSites/SecurityWebSite/Startup.cs b/src/Mvc/test/WebSites/SecurityWebSite/Startup.cs index 627292d01a0a..e70e49df7491 100644 --- a/src/Mvc/test/WebSites/SecurityWebSite/Startup.cs +++ b/src/Mvc/test/WebSites/SecurityWebSite/Startup.cs @@ -15,7 +15,7 @@ public class Startup public void ConfigureServices(IServiceCollection services) { // Add framework services. - services.AddControllersWithViews().SetCompatibilityVersion(CompatibilityVersion.Latest); + services.AddControllersWithViews(); services.AddAntiforgery(); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(options => { diff --git a/src/Mvc/test/WebSites/SecurityWebSite/StartupWithGlobalAuthFilter.cs b/src/Mvc/test/WebSites/SecurityWebSite/StartupWithGlobalAuthFilter.cs index f94c2712dd48..c467b1b7a151 100644 --- a/src/Mvc/test/WebSites/SecurityWebSite/StartupWithGlobalAuthFilter.cs +++ b/src/Mvc/test/WebSites/SecurityWebSite/StartupWithGlobalAuthFilter.cs @@ -35,8 +35,7 @@ public void ConfigureServices(IServiceCollection services) { options.Conventions.AllowAnonymousToPage("/AllowAnonymousPageViaConvention"); options.Conventions.AuthorizePage("/AuthorizePageViaConvention", "RequireClaimB"); - }) - .SetCompatibilityVersion(CompatibilityVersion.Latest); + }); } public void Configure(IApplicationBuilder app) diff --git a/src/Mvc/test/WebSites/SecurityWebSite/StartupWithGlobalAuthFilterWithoutEndpointRouting.cs b/src/Mvc/test/WebSites/SecurityWebSite/StartupWithGlobalAuthFilterWithoutEndpointRouting.cs index 41c88d81ce4a..89b1e4fe5c2c 100644 --- a/src/Mvc/test/WebSites/SecurityWebSite/StartupWithGlobalAuthFilterWithoutEndpointRouting.cs +++ b/src/Mvc/test/WebSites/SecurityWebSite/StartupWithGlobalAuthFilterWithoutEndpointRouting.cs @@ -36,8 +36,7 @@ public void ConfigureServices(IServiceCollection services) { options.Conventions.AllowAnonymousToPage("/AllowAnonymousPageViaConvention"); options.Conventions.AuthorizePage("/AuthorizePageViaConvention", "RequireClaimB"); - }) - .SetCompatibilityVersion(CompatibilityVersion.Latest); + }); } public void Configure(IApplicationBuilder app) diff --git a/src/Mvc/test/WebSites/SecurityWebSite/StartupWithGlobalDenyAnonymousFilter.cs b/src/Mvc/test/WebSites/SecurityWebSite/StartupWithGlobalDenyAnonymousFilter.cs index 2a0ba818868e..87f1563711cf 100644 --- a/src/Mvc/test/WebSites/SecurityWebSite/StartupWithGlobalDenyAnonymousFilter.cs +++ b/src/Mvc/test/WebSites/SecurityWebSite/StartupWithGlobalDenyAnonymousFilter.cs @@ -25,8 +25,7 @@ public void ConfigureServices(IServiceCollection services) services.AddMvc(o => { o.Filters.Add(new AuthorizeFilter()); - }) - .SetCompatibilityVersion(CompatibilityVersion.Latest); + }); services.AddScoped(); } diff --git a/src/Mvc/test/WebSites/SecurityWebSite/StartupWithGlobalDenyAnonymousFilterWithUseMvc.cs b/src/Mvc/test/WebSites/SecurityWebSite/StartupWithGlobalDenyAnonymousFilterWithUseMvc.cs index 3bed81bf478d..e9e2c566e496 100644 --- a/src/Mvc/test/WebSites/SecurityWebSite/StartupWithGlobalDenyAnonymousFilterWithUseMvc.cs +++ b/src/Mvc/test/WebSites/SecurityWebSite/StartupWithGlobalDenyAnonymousFilterWithUseMvc.cs @@ -32,8 +32,7 @@ public void ConfigureServices(IServiceCollection services) { o.EnableEndpointRouting = false; o.Filters.Add(new AuthorizeFilter()); - }) - .SetCompatibilityVersion(CompatibilityVersion.Latest); + }); services.AddScoped(); } diff --git a/src/Mvc/test/WebSites/SecurityWebSite/StartupWithRequireAuth.cs b/src/Mvc/test/WebSites/SecurityWebSite/StartupWithRequireAuth.cs index 6f28bfdd3a09..f7891cf3ab5d 100644 --- a/src/Mvc/test/WebSites/SecurityWebSite/StartupWithRequireAuth.cs +++ b/src/Mvc/test/WebSites/SecurityWebSite/StartupWithRequireAuth.cs @@ -15,7 +15,7 @@ public class StartupWithRequireAuth public void ConfigureServices(IServiceCollection services) { // Add framework services. - services.AddControllersWithViews().SetCompatibilityVersion(CompatibilityVersion.Latest); + services.AddControllersWithViews(); services.AddRazorPages(); services.AddAntiforgery(); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(options => diff --git a/src/Mvc/test/WebSites/SecurityWebSite/StartupWithUseMvc.cs b/src/Mvc/test/WebSites/SecurityWebSite/StartupWithUseMvc.cs index 74cebe7eac66..bfd4ccb6a27b 100644 --- a/src/Mvc/test/WebSites/SecurityWebSite/StartupWithUseMvc.cs +++ b/src/Mvc/test/WebSites/SecurityWebSite/StartupWithUseMvc.cs @@ -15,10 +15,9 @@ public class StartupWithUseMvc public void ConfigureServices(IServiceCollection services) { // Add framework services. - services.AddMvc(options => options.EnableEndpointRouting = false) - .SetCompatibilityVersion(CompatibilityVersion.Latest); + services.AddMvc(options => options.EnableEndpointRouting = false); services.AddAntiforgery(); - services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(options => + services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme).AddCookie(options => { options.LoginPath = "/Home/Login"; options.LogoutPath = "/Home/Logout"; diff --git a/src/Mvc/test/WebSites/SimpleWebSite/Startup.cs b/src/Mvc/test/WebSites/SimpleWebSite/Startup.cs index 8f14d68158fd..3bc3b568ebd2 100644 --- a/src/Mvc/test/WebSites/SimpleWebSite/Startup.cs +++ b/src/Mvc/test/WebSites/SimpleWebSite/Startup.cs @@ -20,8 +20,7 @@ public void ConfigureServices(IServiceCollection services) .AddMvcCore() .AddAuthorization() .AddFormatterMappings(m => m.SetMediaTypeMappingForFormat("js", new MediaTypeHeaderValue("application/json"))) - .AddNewtonsoftJson(options => options.SerializerSettings.Formatting = Formatting.Indented) - .SetCompatibilityVersion(CompatibilityVersion.Latest); + .AddNewtonsoftJson(options => options.SerializerSettings.Formatting = Formatting.Indented); } public void Configure(IApplicationBuilder app) diff --git a/src/Mvc/test/WebSites/TagHelpersWebSite/Startup.cs b/src/Mvc/test/WebSites/TagHelpersWebSite/Startup.cs index 8fbc7a520e96..7da912507b60 100644 --- a/src/Mvc/test/WebSites/TagHelpersWebSite/Startup.cs +++ b/src/Mvc/test/WebSites/TagHelpersWebSite/Startup.cs @@ -15,8 +15,7 @@ public class Startup // Set up application services public void ConfigureServices(IServiceCollection services) { - services.AddControllersWithViews() - .SetCompatibilityVersion(CompatibilityVersion.Latest); + services.AddControllersWithViews(); } public void Configure(IApplicationBuilder app) diff --git a/src/Mvc/test/WebSites/VersioningWebSite/Startup.cs b/src/Mvc/test/WebSites/VersioningWebSite/Startup.cs index 88510f4a9e45..4a1f66e12811 100644 --- a/src/Mvc/test/WebSites/VersioningWebSite/Startup.cs +++ b/src/Mvc/test/WebSites/VersioningWebSite/Startup.cs @@ -13,8 +13,7 @@ public class Startup public void ConfigureServices(IServiceCollection services) { services.AddControllers(ConfigureMvcOptions) - .AddNewtonsoftJson() - .SetCompatibilityVersion(CompatibilityVersion.Latest); + .AddNewtonsoftJson(); services.AddScoped(); services.AddSingleton(); diff --git a/src/Mvc/test/WebSites/XmlFormattersWebSite/Startup.cs b/src/Mvc/test/WebSites/XmlFormattersWebSite/Startup.cs index 10466f26c746..21e00674a7a0 100644 --- a/src/Mvc/test/WebSites/XmlFormattersWebSite/Startup.cs +++ b/src/Mvc/test/WebSites/XmlFormattersWebSite/Startup.cs @@ -13,16 +13,13 @@ namespace XmlFormattersWebSite { public class Startup { - public virtual CompatibilityVersion CompatibilityVersion => CompatibilityVersion.Latest; - // Set up application services public void ConfigureServices(IServiceCollection services) { // Add MVC services to the services container services.AddControllers() .AddXmlDataContractSerializerFormatters() - .AddXmlSerializerFormatters() - .SetCompatibilityVersion(CompatibilityVersion); + .AddXmlSerializerFormatters(); services.Configure(options => { diff --git a/src/Tools/Microsoft.dotnet-openapi/test/TestContent/Startup.cs.txt b/src/Tools/Microsoft.dotnet-openapi/test/TestContent/Startup.cs.txt index edea5132c820..f29b32d3e298 100644 --- a/src/Tools/Microsoft.dotnet-openapi/test/TestContent/Startup.cs.txt +++ b/src/Tools/Microsoft.dotnet-openapi/test/TestContent/Startup.cs.txt @@ -19,8 +19,7 @@ namespace SimpleWebSite services .AddMvcCore() .AddAuthorization() - .AddFormatterMappings(m => m.SetMediaTypeMappingForFormat("js", new MediaTypeHeaderValue("application/json"))) - .SetCompatibilityVersion(CompatibilityVersion.Latest); + .AddFormatterMappings(m => m.SetMediaTypeMappingForFormat("js", new MediaTypeHeaderValue("application/json"))); } public void Configure(IApplicationBuilder app)