Skip to content

Commit 72c74e3

Browse files
committed
Remove obsolete APIs from MVC
Fixes #7322
1 parent e3d0dc0 commit 72c74e3

File tree

48 files changed

+70
-2086
lines changed

Some content is hidden

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

48 files changed

+70
-2086
lines changed

src/Mvc/src/Microsoft.AspNetCore.Mvc.Abstractions/Formatters/OutputFormatterCanWriteContext.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,6 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
1212
/// </summary>
1313
public abstract class OutputFormatterCanWriteContext
1414
{
15-
/// <summary>
16-
/// <para>
17-
/// This constructor is obsolete and will be removed in a future version.
18-
/// Please use <see cref="OutputFormatterCanWriteContext(Http.HttpContext)"/> instead.
19-
/// </para>
20-
/// <para>
21-
/// Creates a new <see cref="OutputFormatterCanWriteContext"/>.
22-
/// </para>
23-
/// </summary>
24-
[Obsolete("This constructor is obsolete and will be removed in a future version. Please use the constructor taking a HttpContext instead.")]
25-
protected OutputFormatterCanWriteContext()
26-
{
27-
}
28-
2915
/// <summary>
3016
/// Creates a new <see cref="OutputFormatterCanWriteContext"/>.
3117
/// </summary>

src/Mvc/src/Microsoft.AspNetCore.Mvc.ApiExplorer/DefaultApiDescriptionProvider.cs

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -29,44 +29,6 @@ public class DefaultApiDescriptionProvider : IApiDescriptionProvider
2929
private readonly IInlineConstraintResolver _constraintResolver;
3030
private readonly IModelMetadataProvider _modelMetadataProvider;
3131

32-
/// <summary>
33-
/// Creates a new instance of <see cref="DefaultApiDescriptionProvider"/>.
34-
/// </summary>
35-
/// <param name="optionsAccessor">The accessor for <see cref="MvcOptions"/>.</param>
36-
/// <param name="constraintResolver">The <see cref="IInlineConstraintResolver"/> used for resolving inline
37-
/// constraints.</param>
38-
/// <param name="modelMetadataProvider">The <see cref="IModelMetadataProvider"/>.</param>
39-
[Obsolete("This constructor is obsolete and will be removed in a future release.")]
40-
public DefaultApiDescriptionProvider(
41-
IOptions<MvcOptions> optionsAccessor,
42-
IInlineConstraintResolver constraintResolver,
43-
IModelMetadataProvider modelMetadataProvider)
44-
: this(optionsAccessor, constraintResolver, modelMetadataProvider, null)
45-
{
46-
}
47-
48-
/// <summary>
49-
/// Creates a new instance of <see cref="DefaultApiDescriptionProvider"/>.
50-
/// </summary>
51-
/// <param name="optionsAccessor">The accessor for <see cref="MvcOptions"/>.</param>
52-
/// <param name="constraintResolver">The <see cref="IInlineConstraintResolver"/> used for resolving inline
53-
/// constraints.</param>
54-
/// <param name="modelMetadataProvider">The <see cref="IModelMetadataProvider"/>.</param>
55-
/// <param name="mapper">The <see cref="IActionResultTypeMapper"/>.</param>
56-
/// <remarks>The <paramref name="mapper"/> parameter is currently ignored.</remarks>
57-
[Obsolete("This constructor is obsolete and will be removed in a future release.")]
58-
public DefaultApiDescriptionProvider(
59-
IOptions<MvcOptions> optionsAccessor,
60-
IInlineConstraintResolver constraintResolver,
61-
IModelMetadataProvider modelMetadataProvider,
62-
IActionResultTypeMapper mapper)
63-
{
64-
_mvcOptions = optionsAccessor.Value;
65-
_constraintResolver = constraintResolver;
66-
_modelMetadataProvider = modelMetadataProvider;
67-
_responseTypeProvider = new ApiResponseTypeProvider(modelMetadataProvider, mapper, _mvcOptions);
68-
}
69-
7032
/// <summary>
7133
/// Creates a new instance of <see cref="DefaultApiDescriptionProvider"/>.
7234
/// </summary>

src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/Formatters/FormatFilter.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@ public class FormatFilter : IFormatFilter, IResourceFilter, IResultFilter
2121
private readonly MvcOptions _options;
2222
private readonly ILogger _logger;
2323

24-
/// <summary>
25-
/// Initializes an instance of <see cref="FormatFilter"/>.
26-
/// </summary>
27-
/// <param name="options">The <see cref="IOptions{MvcOptions}"/></param>
28-
[Obsolete("This constructor is obsolete and will be removed in a future version.")]
29-
public FormatFilter(IOptions<MvcOptions> options)
30-
: this(options, NullLoggerFactory.Instance)
31-
{
32-
}
33-
3424
/// <summary>
3525
/// Initializes an instance of <see cref="FormatFilter"/>.
3626
/// </summary>

src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/LocalRedirectResult.cs

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -104,42 +104,5 @@ public override Task ExecuteResultAsync(ActionContext context)
104104
var executor = context.HttpContext.RequestServices.GetRequiredService<IActionResultExecutor<LocalRedirectResult>>();
105105
return executor.ExecuteAsync(context, this);
106106
}
107-
108-
#pragma warning disable CS0809
109-
[Obsolete("This implementation will be removed in a future release, use ExecuteResultAsync.")]
110-
public override void ExecuteResult(ActionContext context)
111-
{
112-
if (context == null)
113-
{
114-
throw new ArgumentNullException(nameof(context));
115-
}
116-
117-
var services = context.HttpContext.RequestServices;
118-
var urlHelperFactory = services.GetRequiredService<IUrlHelperFactory>();
119-
var logger = services.GetRequiredService<ILogger<LocalRedirectResult>>();
120-
121-
var urlHelper = UrlHelper ?? urlHelperFactory.GetUrlHelper(context);
122-
123-
// IsLocalUrl is called to handle Urls starting with '~/'.
124-
if (!urlHelper.IsLocalUrl(Url))
125-
{
126-
throw new InvalidOperationException(Resources.UrlNotLocal);
127-
}
128-
129-
var destinationUrl = urlHelper.Content(Url);
130-
logger.LocalRedirectResultExecuting(destinationUrl);
131-
132-
if (PreserveMethod)
133-
{
134-
context.HttpContext.Response.StatusCode = Permanent ?
135-
StatusCodes.Status308PermanentRedirect : StatusCodes.Status307TemporaryRedirect;
136-
context.HttpContext.Response.Headers[HeaderNames.Location] = destinationUrl;
137-
}
138-
else
139-
{
140-
context.HttpContext.Response.Redirect(destinationUrl, Permanent);
141-
}
142-
}
143-
#pragma warning restore CS0809
144107
}
145108
}

src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/ArrayModelBinder.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Diagnostics;
77
using System.Linq;
88
using Microsoft.Extensions.Logging;
9-
using Microsoft.Extensions.Logging.Abstractions;
109

1110
namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
1211
{
@@ -16,21 +15,6 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
1615
/// <typeparam name="TElement">Type of elements in the array.</typeparam>
1716
public class ArrayModelBinder<TElement> : CollectionModelBinder<TElement>
1817
{
19-
/// <summary>
20-
/// <para>This constructor is obsolete and will be removed in a future version. The recommended alternative
21-
/// is the overload that also takes an <see cref="ILoggerFactory"/>.</para>
22-
/// <para>Creates a new <see cref="ArrayModelBinder{TElement}"/>.</para>
23-
/// </summary>
24-
/// <param name="elementBinder">
25-
/// The <see cref="IModelBinder"/> for binding <typeparamref name="TElement"/>.
26-
/// </param>
27-
[Obsolete("This constructor is obsolete and will be removed in a future version. The recommended alternative"
28-
+ " is the overload that also takes an " + nameof(ILoggerFactory) + ".")]
29-
public ArrayModelBinder(IModelBinder elementBinder)
30-
: this(elementBinder, NullLoggerFactory.Instance)
31-
{
32-
}
33-
3418
/// <summary>
3519
/// Creates a new <see cref="ArrayModelBinder{TElement}"/>.
3620
/// </summary>

src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/ByteArrayModelBinder.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System;
55
using System.Threading.Tasks;
66
using Microsoft.Extensions.Logging;
7-
using Microsoft.Extensions.Logging.Abstractions;
87

98
namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
109
{
@@ -15,18 +14,6 @@ public class ByteArrayModelBinder : IModelBinder
1514
{
1615
private readonly ILogger _logger;
1716

18-
/// <summary>
19-
/// <para>This constructor is obsolete and will be removed in a future version. The recommended alternative
20-
/// is the overload that takes an <see cref="ILoggerFactory"/>.</para>
21-
/// <para>Initializes a new instance of <see cref="ByteArrayModelBinder"/>.</para>
22-
/// </summary>
23-
[Obsolete("This constructor is obsolete and will be removed in a future version. The recommended alternative"
24-
+ " is the overload that takes an " + nameof(ILoggerFactory) + ".")]
25-
public ByteArrayModelBinder()
26-
: this(NullLoggerFactory.Instance)
27-
{
28-
}
29-
3017
/// <summary>
3118
/// Initializes a new instance of <see cref="ByteArrayModelBinder"/>.
3219
/// </summary>

src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/CollectionModelBinder.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
using System.Threading.Tasks;
1212
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
1313
using Microsoft.Extensions.Logging;
14-
using Microsoft.Extensions.Logging.Abstractions;
1514

1615
namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
1716
{
@@ -24,19 +23,6 @@ public class CollectionModelBinder<TElement> : ICollectionModelBinder
2423
private static readonly IValueProvider EmptyValueProvider = new CompositeValueProvider();
2524
private Func<object> _modelCreator;
2625

27-
/// <summary>
28-
/// <para>This constructor is obsolete and will be removed in a future version. The recommended alternative
29-
/// is the overload that also takes an <see cref="ILoggerFactory"/>.</para>
30-
/// <para>Creates a new <see cref="CollectionModelBinder{TElement}"/>.</para>
31-
/// </summary>
32-
/// <param name="elementBinder">The <see cref="IModelBinder"/> for binding elements.</param>
33-
[Obsolete("This constructor is obsolete and will be removed in a future version. The recommended alternative"
34-
+ " is the overload that also takes an " + nameof(ILoggerFactory) + ".")]
35-
public CollectionModelBinder(IModelBinder elementBinder)
36-
: this(elementBinder, NullLoggerFactory.Instance)
37-
{
38-
}
39-
4026
/// <summary>
4127
/// Creates a new <see cref="CollectionModelBinder{TElement}"/>.
4228
/// </summary>

src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/ComplexTypeModelBinder.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using Microsoft.AspNetCore.Mvc.Core;
1010
using Microsoft.AspNetCore.Mvc.ModelBinding.Metadata;
1111
using Microsoft.Extensions.Logging;
12-
using Microsoft.Extensions.Logging.Abstractions;
1312

1413
namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
1514
{
@@ -22,21 +21,6 @@ public class ComplexTypeModelBinder : IModelBinder
2221
private readonly ILogger _logger;
2322
private Func<object> _modelCreator;
2423

25-
/// <summary>
26-
/// <para>This constructor is obsolete and will be removed in a future version. The recommended alternative
27-
/// is the overload that also takes an <see cref="ILoggerFactory"/>.</para>
28-
/// <para>Creates a new <see cref="ComplexTypeModelBinder"/>.</para>
29-
/// </summary>
30-
/// <param name="propertyBinders">
31-
/// The <see cref="IDictionary{TKey, TValue}"/> of binders to use for binding properties.
32-
/// </param>
33-
[Obsolete("This constructor is obsolete and will be removed in a future version. The recommended alternative"
34-
+ " is the overload that also takes an " + nameof(ILoggerFactory) + ".")]
35-
public ComplexTypeModelBinder(IDictionary<ModelMetadata, IModelBinder> propertyBinders)
36-
: this(propertyBinders, NullLoggerFactory.Instance)
37-
{
38-
}
39-
4024
/// <summary>
4125
/// Creates a new <see cref="ComplexTypeModelBinder"/>.
4226
/// </summary>

src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/DecimalModelBinder.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Runtime.ExceptionServices;
77
using System.Threading.Tasks;
88
using Microsoft.Extensions.Logging;
9-
using Microsoft.Extensions.Logging.Abstractions;
109

1110
namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
1211
{
@@ -19,19 +18,6 @@ public class DecimalModelBinder : IModelBinder
1918
private readonly NumberStyles _supportedStyles;
2019
private readonly ILogger _logger;
2120

22-
/// <summary>
23-
/// <para>This constructor is obsolete and will be removed in a future version. The recommended alternative
24-
/// is the overload that also takes an <see cref="ILoggerFactory"/>.</para>
25-
/// <para>Initializes a new instance of <see cref="DecimalModelBinder"/>.</para>
26-
/// </summary>
27-
/// <param name="supportedStyles">The <see cref="NumberStyles"/>.</param>
28-
[Obsolete("This constructor is obsolete and will be removed in a future version. The recommended alternative"
29-
+ " is the overload that also takes an " + nameof(ILoggerFactory) + ".")]
30-
public DecimalModelBinder(NumberStyles supportedStyles)
31-
: this(supportedStyles, NullLoggerFactory.Instance)
32-
{
33-
}
34-
3521
/// <summary>
3622
/// Initializes a new instance of <see cref="DecimalModelBinder"/>.
3723
/// </summary>

src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/DictionaryModelBinder.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.Threading.Tasks;
99
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
1010
using Microsoft.Extensions.Logging;
11-
using Microsoft.Extensions.Logging.Abstractions;
1211

1312
namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
1413
{
@@ -21,20 +20,6 @@ public class DictionaryModelBinder<TKey, TValue> : CollectionModelBinder<KeyValu
2120
{
2221
private readonly IModelBinder _valueBinder;
2322

24-
/// <summary>
25-
/// <para>This constructor is obsolete and will be removed in a future version. The recommended alternative
26-
/// is the overload that also takes an <see cref="ILoggerFactory"/>.</para>
27-
/// <para>Creates a new <see cref="DictionaryModelBinder{TKey, TValue}"/>.</para>
28-
/// </summary>
29-
/// <param name="keyBinder">The <see cref="IModelBinder"/> for <typeparamref name="TKey"/>.</param>
30-
/// <param name="valueBinder">The <see cref="IModelBinder"/> for <typeparamref name="TValue"/>.</param>
31-
[Obsolete("This constructor is obsolete and will be removed in a future version. The recommended alternative"
32-
+ " is the overload that also takes an " + nameof(ILoggerFactory) + ".")]
33-
public DictionaryModelBinder(IModelBinder keyBinder, IModelBinder valueBinder)
34-
: this(keyBinder, valueBinder, NullLoggerFactory.Instance)
35-
{
36-
}
37-
3823
/// <summary>
3924
/// Creates a new <see cref="DictionaryModelBinder{TKey, TValue}"/>.
4025
/// </summary>

src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/DoubleModelBinder.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Runtime.ExceptionServices;
77
using System.Threading.Tasks;
88
using Microsoft.Extensions.Logging;
9-
using Microsoft.Extensions.Logging.Abstractions;
109

1110
namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
1211
{
@@ -19,19 +18,6 @@ public class DoubleModelBinder : IModelBinder
1918
private readonly NumberStyles _supportedStyles;
2019
private readonly ILogger _logger;
2120

22-
/// <summary>
23-
/// <para>This constructor is obsolete and will be removed in a future version. The recommended alternative
24-
/// is the overload that also takes an <see cref="ILoggerFactory"/>.</para>
25-
/// <para>Initializes a new instance of <see cref="DoubleModelBinder"/>.</para>
26-
/// </summary>
27-
/// <param name="supportedStyles">The <see cref="NumberStyles"/>.</param>
28-
[Obsolete("This constructor is obsolete and will be removed in a future version. The recommended alternative"
29-
+ " is the overload that also takes an " + nameof(ILoggerFactory) + ".")]
30-
public DoubleModelBinder(NumberStyles supportedStyles)
31-
: this(supportedStyles, NullLoggerFactory.Instance)
32-
{
33-
}
34-
3521
/// <summary>
3622
/// Initializes a new instance of <see cref="DoubleModelBinder"/>.
3723
/// </summary>

src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/FloatModelBinder.cs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using System.Runtime.ExceptionServices;
77
using System.Threading.Tasks;
88
using Microsoft.Extensions.Logging;
9-
using Microsoft.Extensions.Logging.Abstractions;
109

1110
namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
1211
{
@@ -19,19 +18,6 @@ public class FloatModelBinder : IModelBinder
1918
private readonly NumberStyles _supportedStyles;
2019
private readonly ILogger _logger;
2120

22-
/// <summary>
23-
/// <para>This constructor is obsolete and will be removed in a future version. The recommended alternative
24-
/// is the overload that also takes an <see cref="ILoggerFactory"/>.</para>
25-
/// <para>Initializes a new instance of <see cref="FloatModelBinder"/>.</para>
26-
/// </summary>
27-
/// <param name="supportedStyles">The <see cref="NumberStyles"/>.</param>
28-
[Obsolete("This constructor is obsolete and will be removed in a future version. The recommended alternative"
29-
+ " is the overload that also takes an " + nameof(ILoggerFactory) + ".")]
30-
public FloatModelBinder(NumberStyles supportedStyles)
31-
: this(supportedStyles, NullLoggerFactory.Instance)
32-
{
33-
}
34-
3521
/// <summary>
3622
/// Initializes a new instance of <see cref="FloatModelBinder"/>.
3723
/// </summary>

src/Mvc/src/Microsoft.AspNetCore.Mvc.Core/ModelBinding/Binders/FormCollectionModelBinder.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
using System.Threading.Tasks;
99
using Microsoft.AspNetCore.Http;
1010
using Microsoft.Extensions.Logging;
11-
using Microsoft.Extensions.Logging.Abstractions;
1211
using Microsoft.Extensions.Primitives;
1312

1413
namespace Microsoft.AspNetCore.Mvc.ModelBinding.Binders
@@ -20,18 +19,6 @@ public class FormCollectionModelBinder : IModelBinder
2019
{
2120
private readonly ILogger _logger;
2221

23-
/// <summary>
24-
/// <para>This constructor is obsolete and will be removed in a future version. The recommended alternative
25-
/// is the overload that takes an <see cref="ILoggerFactory"/>.</para>
26-
/// <para>Initializes a new instance of <see cref="FormCollectionModelBinder"/>.</para>
27-
/// </summary>
28-
[Obsolete("This constructor is obsolete and will be removed in a future version. The recommended alternative"
29-
+ " is the overload that takes an " + nameof(ILoggerFactory) + ".")]
30-
public FormCollectionModelBinder()
31-
: this(NullLoggerFactory.Instance)
32-
{
33-
}
34-
3522
/// <summary>
3623
/// Initializes a new instance of <see cref="FormCollectionModelBinder"/>.
3724
/// </summary>

0 commit comments

Comments
 (0)