Skip to content

Commit 0c18367

Browse files
captainsafiapranavkm
authored andcommitted
Clean up obsolete APIs in MVC
1 parent 4900ad4 commit 0c18367

File tree

69 files changed

+86
-194
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+86
-194
lines changed

src/Mvc/Mvc.Abstractions/src/ModelBinding/Metadata/ModelMetadataIdentity.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public static ModelMetadataIdentity ForType(Type modelType)
4848
/// <param name="name">The name of the property.</param>
4949
/// <param name="containerType">The container type of the model property.</param>
5050
/// <returns>A <see cref="ModelMetadataIdentity"/>.</returns>
51-
[Obsolete("This API is obsolete and may be removed in a future release.")]
51+
[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.
5252
public static ModelMetadataIdentity ForProperty(
5353
Type modelType,
5454
string name,
@@ -224,7 +224,7 @@ public bool Equals(ModelMetadataIdentity other)
224224
ContainerType == other.ContainerType &&
225225
ModelType == other.ModelType &&
226226
Name == other.Name &&
227-
ParameterInfo == other.ParameterInfo &&
227+
ParameterInfo == other.ParameterInfo &&
228228
PropertyInfo == other.PropertyInfo &&
229229
ConstructorInfo == other.ConstructorInfo;
230230
}

src/Mvc/Mvc.Core/src/CompatibilityVersion.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
@@ -37,14 +37,17 @@ namespace Microsoft.AspNetCore.Mvc
3737
/// settings to match a particular minor release of ASP.NET Core MVC.
3838
/// </para>
3939
/// </remarks>
40+
// Remove after .NET 6.
41+
[Obsolete("This API is obsolete and will be removed in a future version. Consider removing usages.",
42+
DiagnosticId = "ASP5001",
43+
UrlFormat = "https://aka.ms/aspnetcore-warnings/{0}")]
4044
public enum CompatibilityVersion
4145
{
4246
/// <summary>
4347
/// Sets the default value of settings on <see cref="MvcOptions"/> to match the behavior of
4448
/// ASP.NET Core MVC 2.0.
4549
/// </summary>
46-
[Obsolete("This " + nameof(CompatibilityVersion) + " value is obsolete. The recommended alternatives are " +
47-
nameof(Version_3_0) + " or later.")]
50+
[Obsolete("This " + nameof(CompatibilityVersion) + " value is obsolete.")]
4851
Version_2_0,
4952

5053
/// <summary>
@@ -55,8 +58,7 @@ public enum CompatibilityVersion
5558
/// ASP.NET Core MVC 2.1 introduced a compatibility switch for
5659
/// <c>MvcJsonOptions.AllowInputFormatterExceptionMessages</c>. This is now a regular property.
5760
/// </remarks>
58-
[Obsolete("This " + nameof(CompatibilityVersion) + " value is obsolete. The recommended alternatives are " +
59-
nameof(Version_3_0) + " or later.")]
61+
[Obsolete("This " + nameof(CompatibilityVersion) + " value is obsolete.")]
6062
Version_2_1,
6163

6264
/// <summary>
@@ -72,20 +74,21 @@ public enum CompatibilityVersion
7274
/// </list>
7375
/// All of the above are now regular properties.
7476
/// </remarks>
75-
[Obsolete("This " + nameof(CompatibilityVersion) + " value is obsolete. The recommended alternatives are " +
76-
nameof(Version_3_0) + " or later.")]
77+
[Obsolete("This " + nameof(CompatibilityVersion) + " value is obsolete.")]
7778
Version_2_2,
7879

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

8587
/// <summary>
8688
/// Sets the default value of settings on <see cref="MvcOptions"/> to match the latest release. Use this
8789
/// value with care, upgrading minor versions will cause breaking changes when using <see cref="Latest"/>.
8890
/// </summary>
91+
[Obsolete("This " + nameof(CompatibilityVersion) + " value is obsolete.")]
8992
Latest = int.MaxValue,
9093
}
9194
}

src/Mvc/Mvc.Core/src/DependencyInjection/MvcCoreMvcBuilderExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,9 @@ public static IMvcBuilder AddControllersAsServices(this IMvcBuilder builder)
178178
/// <param name="builder">The <see cref="IMvcBuilder"/>.</param>
179179
/// <param name="version">The <see cref="CompatibilityVersion"/> value to configure.</param>
180180
/// <returns>The <see cref="IMvcBuilder"/>.</returns>
181+
[Obsolete("This API is obsolete and will be removed in a future version. Consider removing usages.",
182+
DiagnosticId = "ASP5001",
183+
UrlFormat = "https://aka.ms/aspnetcore-warnings/{0}")]
181184
public static IMvcBuilder SetCompatibilityVersion(this IMvcBuilder builder, CompatibilityVersion version)
182185
{
183186
if (builder == null)

src/Mvc/Mvc.Core/src/DependencyInjection/MvcCoreMvcCoreBuilderExtensions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ public static IMvcCoreBuilder ConfigureApiBehaviorOptions(
254254
/// <param name="builder">The <see cref="IMvcCoreBuilder"/>.</param>
255255
/// <param name="version">The <see cref="CompatibilityVersion"/> value to configure.</param>
256256
/// <returns>The <see cref="IMvcCoreBuilder"/>.</returns>
257+
[Obsolete("This API is obsolete and will be removed in a future version. Consider removing usages.",
258+
DiagnosticId = "ASP5001",
259+
UrlFormat = "https://aka.ms/aspnetcore-warnings/{0}")]
257260
public static IMvcCoreBuilder SetCompatibilityVersion(this IMvcCoreBuilder builder, CompatibilityVersion version)
258261
{
259262
if (builder == null)

src/Mvc/Mvc.Core/src/DependencyInjection/MvcCoreServiceCollectionExtensions.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,6 @@ internal static void AddMvcCoreServices(IServiceCollection services)
143143
//
144144
services.TryAddEnumerable(
145145
ServiceDescriptor.Transient<IConfigureOptions<MvcOptions>, MvcCoreMvcOptionsSetup>());
146-
services.TryAddEnumerable(
147-
ServiceDescriptor.Transient<IPostConfigureOptions<MvcOptions>, MvcOptionsConfigureCompatibilityOptions>());
148146
services.TryAddEnumerable(
149147
ServiceDescriptor.Transient<IPostConfigureOptions<MvcOptions>, MvcCoreMvcOptionsSetup>());
150148
services.TryAddEnumerable(

src/Mvc/Mvc.Core/src/Infrastructure/ConfigureCompatibilityOptions.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
using System;
@@ -14,6 +14,9 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
1414
/// by application code.
1515
/// </summary>
1616
/// <typeparam name="TOptions"></typeparam>
17+
[Obsolete("This API is obsolete and will be removed in a future version. Consider removing usages.",
18+
DiagnosticId = "ASP5001",
19+
UrlFormat = "https://aka.ms/aspnetcore-warnings/{0}")]
1720
public abstract class ConfigureCompatibilityOptions<TOptions> : IPostConfigureOptions<TOptions>
1821
where TOptions : class, IEnumerable<ICompatibilitySwitch>
1922
{

src/Mvc/Mvc.Core/src/Infrastructure/MvcCompatibilityOptions.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

4+
using System;
45
using Microsoft.Extensions.DependencyInjection;
56

67
namespace Microsoft.AspNetCore.Mvc.Infrastructure
@@ -13,6 +14,9 @@ namespace Microsoft.AspNetCore.Mvc.Infrastructure
1314
/// calling <see cref="MvcCoreMvcBuilderExtensions.SetCompatibilityVersion(IMvcBuilder, CompatibilityVersion)"/>
1415
/// or <see cref="MvcCoreMvcCoreBuilderExtensions.SetCompatibilityVersion(IMvcCoreBuilder, CompatibilityVersion)"/>.
1516
/// </remarks>
17+
[Obsolete("This API is obsolete and will be removed in a future version. Consider removing usages.",
18+
DiagnosticId = "ASP5001",
19+
UrlFormat = "https://aka.ms/aspnetcore-warnings/{0}")]
1620
public class MvcCompatibilityOptions
1721
{
1822
/// <summary>

src/Mvc/Mvc.Core/src/Infrastructure/MvcOptionsConfigureCompatibilityOptions.cs

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/Mvc/Mvc.Core/src/Infrastructure/ObjectResultExecutor.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,6 @@ public class ObjectResultExecutor : IActionResultExecutor<ObjectResult>
2222
{
2323
private readonly AsyncEnumerableReader _asyncEnumerableReaderFactory;
2424

25-
/// <summary>
26-
/// Creates a new <see cref="ObjectResultExecutor"/>.
27-
/// </summary>
28-
/// <param name="formatterSelector">The <see cref="OutputFormatterSelector"/>.</param>
29-
/// <param name="writerFactory">The <see cref="IHttpResponseStreamWriterFactory"/>.</param>
30-
/// <param name="loggerFactory">The <see cref="ILoggerFactory"/>.</param>
31-
[Obsolete("This constructor is obsolete and will be removed in a future release.")]
32-
public ObjectResultExecutor(
33-
OutputFormatterSelector formatterSelector,
34-
IHttpResponseStreamWriterFactory writerFactory,
35-
ILoggerFactory loggerFactory)
36-
: this(formatterSelector, writerFactory, loggerFactory, mvcOptions: null)
37-
{
38-
}
39-
4025
/// <summary>
4126
/// Creates a new <see cref="ObjectResultExecutor"/>.
4227
/// </summary>

src/Mvc/Mvc.Core/src/Infrastructure/PhysicalFileResultExecutor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ protected virtual Stream GetFileStream(string path)
127127
FileOptions.Asynchronous | FileOptions.SequentialScan);
128128
}
129129

130+
130131
/// <summary>
131132
/// Get the file metadata for a path.
132133
/// </summary>

0 commit comments

Comments
 (0)