Skip to content

Clean up obsolete APIs in MVC #28337

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
1 commit merged into from
Dec 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static ModelMetadataIdentity ForType(Type modelType)
/// <param name="name">The name of the property.</param>
/// <param name="containerType">The container type of the model property.</param>
/// <returns>A <see cref="ModelMetadataIdentity"/>.</returns>
[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,
Expand Down Expand Up @@ -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;
}
Expand Down
17 changes: 10 additions & 7 deletions src/Mvc/Mvc.Core/src/CompatibilityVersion.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -37,14 +37,17 @@ namespace Microsoft.AspNetCore.Mvc
/// settings to match a particular minor release of ASP.NET Core MVC.
/// </para>
/// </remarks>
// 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
{
/// <summary>
/// Sets the default value of settings on <see cref="MvcOptions"/> to match the behavior of
/// ASP.NET Core MVC 2.0.
/// </summary>
[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,

/// <summary>
Expand All @@ -55,8 +58,7 @@ public enum CompatibilityVersion
/// ASP.NET Core MVC 2.1 introduced a compatibility switch for
/// <c>MvcJsonOptions.AllowInputFormatterExceptionMessages</c>. This is now a regular property.
/// </remarks>
[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,

/// <summary>
Expand All @@ -72,20 +74,21 @@ public enum CompatibilityVersion
/// </list>
/// All of the above are now regular properties.
/// </remarks>
[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,

/// <summary>
/// Sets the default value of settings on <see cref="MvcOptions"/> and other <c>Options</c> types to match
/// the behavior of ASP.NET Core MVC 3.0.
/// </summary>
[Obsolete("This " + nameof(CompatibilityVersion) + " value is obsolete.")]
Version_3_0,

/// <summary>
/// Sets the default value of settings on <see cref="MvcOptions"/> to match the latest release. Use this
/// value with care, upgrading minor versions will cause breaking changes when using <see cref="Latest"/>.
/// </summary>
[Obsolete("This " + nameof(CompatibilityVersion) + " value is obsolete.")]
Latest = int.MaxValue,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ public static IMvcBuilder AddControllersAsServices(this IMvcBuilder builder)
/// <param name="builder">The <see cref="IMvcBuilder"/>.</param>
/// <param name="version">The <see cref="CompatibilityVersion"/> value to configure.</param>
/// <returns>The <see cref="IMvcBuilder"/>.</returns>
[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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ public static IMvcCoreBuilder ConfigureApiBehaviorOptions(
/// <param name="builder">The <see cref="IMvcCoreBuilder"/>.</param>
/// <param name="version">The <see cref="CompatibilityVersion"/> value to configure.</param>
/// <returns>The <see cref="IMvcCoreBuilder"/>.</returns>
[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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ internal static void AddMvcCoreServices(IServiceCollection services)
//
services.TryAddEnumerable(
ServiceDescriptor.Transient<IConfigureOptions<MvcOptions>, MvcCoreMvcOptionsSetup>());
services.TryAddEnumerable(
ServiceDescriptor.Transient<IPostConfigureOptions<MvcOptions>, MvcOptionsConfigureCompatibilityOptions>());
services.TryAddEnumerable(
ServiceDescriptor.Transient<IPostConfigureOptions<MvcOptions>, MvcCoreMvcOptionsSetup>());
services.TryAddEnumerable(
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -14,6 +14,9 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
/// by application code.
/// </summary>
/// <typeparam name="TOptions"></typeparam>
[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<TOptions> : IPostConfigureOptions<TOptions>
where TOptions : class, IEnumerable<ICompatibilitySwitch>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -13,6 +14,9 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
/// calling <see cref="MvcCoreMvcBuilderExtensions.SetCompatibilityVersion(IMvcBuilder, CompatibilityVersion)"/>
/// or <see cref="MvcCoreMvcCoreBuilderExtensions.SetCompatibilityVersion(IMvcCoreBuilder, CompatibilityVersion)"/>.
/// </remarks>
[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
{
/// <summary>
Expand Down

This file was deleted.

15 changes: 0 additions & 15 deletions src/Mvc/Mvc.Core/src/Infrastructure/ObjectResultExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,6 @@ public class ObjectResultExecutor : IActionResultExecutor<ObjectResult>
{
private readonly AsyncEnumerableReader _asyncEnumerableReaderFactory;

/// <summary>
/// Creates a new <see cref="ObjectResultExecutor"/>.
/// </summary>
/// <param name="formatterSelector">The <see cref="OutputFormatterSelector"/>.</param>
/// <param name="writerFactory">The <see cref="IHttpResponseStreamWriterFactory"/>.</param>
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param>
[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)
{
}

/// <summary>
/// Creates a new <see cref="ObjectResultExecutor"/>.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ protected virtual Stream GetFileStream(string path)
FileOptions.Asynchronous | FileOptions.SequentialScan);
}


/// <summary>
/// Get the file metadata for a path.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,6 @@ public int? MaxValidationDepth
/// </summary>
public bool ValidateComplexTypesIfChildValidationFails { get; set; }

/// <summary>
/// Gets or sets a value that determines if <see cref="ValidationVisitor"/> can short circuit validation when a model
/// does not have any associated validators.
/// </summary>
/// <value>The default value is <see langword="true"/>.</value>
/// <remarks>This property is currently ignored.</remarks>
[Obsolete("This property is deprecated and is no longer used by the runtime.")]
public bool AllowShortCircuitingValidationWhenNoValidatorsArePresent { get; set; } = true;

/// <summary>
/// Validates a object.
/// </summary>
Expand Down Expand Up @@ -388,7 +379,7 @@ private bool VisitImplementation(ref ModelMetadata metadata, ref string key, obj
}

/// <summary>
/// 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.
/// </summary>
/// <param name="defaultStrategy">The default validation strategy to use.</param>
/// <returns><see langword="true" /> if valid, otherwise <see langword="false" />.</returns>
Expand Down
3 changes: 0 additions & 3 deletions src/Mvc/Mvc.Core/src/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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<Microsoft.AspNetCore.Mvc.MvcOptions> mvcOptions) -> void
~Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor.WriterFactory.get -> System.Func<System.IO.Stream, System.Text.Encoding, System.IO.TextWriter>
~Microsoft.AspNetCore.Mvc.Infrastructure.PhysicalFileResultExecutor.PhysicalFileResultExecutor(Microsoft.Extensions.Logging.ILoggerFactory loggerFactory) -> void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,6 @@ private Dictionary<Type, Type[]> MultiRegistrationServiceTypes
typeof(IPostConfigureOptions<MvcOptions>),
new Type[]
{
typeof(MvcOptionsConfigureCompatibilityOptions),
typeof(MvcCoreMvcOptionsSetup),
}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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]
Expand Down
6 changes: 0 additions & 6 deletions src/Mvc/Mvc.Localization/test/TestStringLocalizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,5 @@ public IEnumerable<LocalizedString> GetAllStrings(bool includeParentCultures)

return allStrings;
}

[Obsolete("This method is obsolete. Use `CurrentCulture` and `CurrentUICulture` instead.")]
public IStringLocalizer WithCulture(CultureInfo culture)
{
return new TestStringLocalizer(culture);
}
}
}
4 changes: 2 additions & 2 deletions src/Mvc/Mvc.Razor/src/Compilation/CompiledViewDescriptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public CompiledViewDescriptor(RazorCompiledItem item, RazorViewAttribute attribu
/// </summary>
public string RelativePath { get; set; }

#pragma warning disable CS0618
#pragma warning disable CS0618
// Type or member is obsolete
/// <summary>
/// Gets or sets the <see cref="RazorViewAttribute"/> decorating the view.
Expand All @@ -105,4 +105,4 @@ public CompiledViewDescriptor(RazorCompiledItem item, RazorViewAttribute attribu
/// </summary>
public Type Type => Item?.Type;
}
}
}
2 changes: 1 addition & 1 deletion src/Mvc/Mvc.Razor/src/Compilation/RazorViewAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ public RazorViewAttribute(string path, Type viewType)
/// </summary>
public Type ViewType { get; }
}
}
}
4 changes: 2 additions & 2 deletions src/Mvc/Mvc.TagHelpers/src/ImageTagHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,14 @@ public ImageTagHelper(
/// Gets the <see cref="IWebHostEnvironment"/> for the application.
/// This property is obsolete and will be removed in a future version.
/// </summary>
[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; }

/// <summary>
/// Gets the <see cref="IMemoryCache"/> used to store globbed urls.
/// This property is obsolete and will be removed in a future version.
/// </summary>
[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; }
Expand Down
1 change: 0 additions & 1 deletion src/Mvc/Mvc.ViewFeatures/src/PublicAPI.Shipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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<Microsoft.AspNetCore.Mvc.MvcViewOptions> 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<Microsoft.AspNetCore.Mvc.MvcViewOptions> 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<string, object> item) -> void
~Microsoft.AspNetCore.Mvc.ViewFeatures.ViewDataDictionary.Add(string key, object value) -> void
Expand Down
14 changes: 0 additions & 14 deletions src/Mvc/Mvc.ViewFeatures/src/ViewComponentResultExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,6 @@ public class ViewComponentResultExecutor : IActionResultExecutor<ViewComponentRe
private readonly ITempDataDictionaryFactory _tempDataDictionaryFactory;
private IHttpResponseStreamWriterFactory _writerFactory;

/// <summary>
/// This constructor is obsolete and will be removed in a future version.
/// </summary>
[Obsolete("This constructor is obsolete and will be removed in a future version.")]
public ViewComponentResultExecutor(
IOptions<MvcViewOptions> mvcHelperOptions,
ILoggerFactory loggerFactory,
HtmlEncoder htmlEncoder,
IModelMetadataProvider modelMetadataProvider,
ITempDataDictionaryFactory tempDataDictionaryFactory)
: this(mvcHelperOptions, loggerFactory, htmlEncoder, modelMetadataProvider, tempDataDictionaryFactory, null)
{
}

/// <summary>
/// Initialize a new instance of <see cref="ViewComponentResultExecutor"/>
/// </summary>
Expand Down
Loading