Added obsoletion methods for extension methods to be removed in Umbraco 16 (#18394)
* Added obsoletion methods for extension methods to be removed in Umbraco 16. * Updated obsolete messages to reference Umbraco 17 * Fix typo --------- Co-authored-by: mole <nikolajlauridsen@protonmail.ch>
This commit is contained in:
@@ -47,6 +47,7 @@ public static class AssemblyExtensions
|
||||
/// </summary>
|
||||
/// <param name="assembly"></param>
|
||||
/// <returns></returns>
|
||||
[Obsolete("This extension method is no longer used and will be removed in Umbraco 17.")]
|
||||
public static FileInfo GetAssemblyFile(this Assembly assembly)
|
||||
{
|
||||
var codeBase = assembly.Location;
|
||||
@@ -94,6 +95,7 @@ public static class AssemblyExtensions
|
||||
/// </summary>
|
||||
/// <param name="assemblyName"></param>
|
||||
/// <returns></returns>
|
||||
[Obsolete("This extension method is no longer used and will be removed in Umbraco 17.")]
|
||||
public static FileInfo? GetAssemblyFile(this AssemblyName assemblyName)
|
||||
{
|
||||
var codeBase = assemblyName.CodeBase;
|
||||
|
||||
@@ -2,7 +2,7 @@ namespace Umbraco.Cms.Core.Extensions;
|
||||
|
||||
public static class CollectionExtensions
|
||||
{
|
||||
// Easiest way to return a collection with 1 item, probably not the most performant
|
||||
[Obsolete("Please replace uses of this extension method with collection expression. This method will be removed in Umbraco 17.")]
|
||||
public static ICollection<T> ToSingleItemCollection<T>(this T item) =>
|
||||
new T[] { item };
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ public static class DataTableExtensions
|
||||
/// This has been migrated from the Node class and uses proper locking now. It is now used by the Node class and the
|
||||
/// DynamicPublishedContent extensions for legacy reasons.
|
||||
/// </remarks>
|
||||
[Obsolete("This no longer has a use in Umbraco and so will be removed in Umbraco 17.")]
|
||||
public static DataTable GenerateDataTable(
|
||||
string tableAlias,
|
||||
Func<string, IEnumerable<KeyValuePair<string, string>>> getHeaders,
|
||||
@@ -60,6 +61,7 @@ public static class DataTableExtensions
|
||||
/// <remarks>
|
||||
/// This is for legacy code, I didn't want to go creating custom classes for these
|
||||
/// </remarks>
|
||||
[Obsolete("This no longer has a use in Umbraco and so will be removed in Umbraco 17.")]
|
||||
public static List<Tuple<IEnumerable<KeyValuePair<string, object?>>, IEnumerable<KeyValuePair<string, object?>>>>
|
||||
CreateTableData() =>
|
||||
new List<Tuple<IEnumerable<KeyValuePair<string, object?>>, IEnumerable<KeyValuePair<string, object?>>>>();
|
||||
@@ -73,6 +75,7 @@ public static class DataTableExtensions
|
||||
/// <remarks>
|
||||
/// This is for legacy code, I didn't want to go creating custom classes for these
|
||||
/// </remarks>
|
||||
[Obsolete("This no longer has a use in Umbraco and so will be removed in Umbraco 17.")]
|
||||
public static void AddRowData(
|
||||
List<Tuple<IEnumerable<KeyValuePair<string, object?>>, IEnumerable<KeyValuePair<string, object?>>>> rowData,
|
||||
IEnumerable<KeyValuePair<string, object?>> standardVals,
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace Umbraco.Extensions;
|
||||
|
||||
public static class DelegateExtensions
|
||||
{
|
||||
[Obsolete("This method is no longer used in Umbraco. The method will be removed in Umbraco 17.")]
|
||||
public static Attempt<T?> RetryUntilSuccessOrTimeout<T>(this Func<Attempt<T?>> task, TimeSpan timeout, TimeSpan pause)
|
||||
{
|
||||
if (pause.TotalMilliseconds < 0)
|
||||
@@ -31,6 +32,7 @@ public static class DelegateExtensions
|
||||
return Attempt<T?>.Fail();
|
||||
}
|
||||
|
||||
[Obsolete("This method is no longer used in Umbraco. The method will be removed in Umbraco 17.")]
|
||||
public static Attempt<T?> RetryUntilSuccessOrMaxAttempts<T>(this Func<int, Attempt<T?>> task, int totalAttempts, TimeSpan pause)
|
||||
{
|
||||
if (pause.TotalMilliseconds < 0)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) Umbraco.
|
||||
// Copyright (c) Umbraco.
|
||||
// See LICENSE for more details.
|
||||
|
||||
namespace Umbraco.Extensions
|
||||
@@ -17,6 +17,7 @@ namespace Umbraco.Extensions
|
||||
/// <returns>
|
||||
/// <c>true</c> if any of the flags/bits are set within the enum value; otherwise, <c>false</c>.
|
||||
/// </returns>
|
||||
[Obsolete("This method is no longer used in Umbraco. The method will be removed in Umbraco 17.")]
|
||||
public static bool HasFlagAny<T>(this T value, T flags)
|
||||
where T : Enum
|
||||
{
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
// Copyright (c) Umbraco.
|
||||
// See LICENSE for more details.
|
||||
|
||||
using System.Linq.Expressions;
|
||||
|
||||
namespace Umbraco.Cms.Core;
|
||||
|
||||
internal static class ExpressionExtensions
|
||||
{
|
||||
public static Expression<Func<T, bool>> True<T>() => f => true;
|
||||
|
||||
public static Expression<Func<T, bool>> False<T>() => f => false;
|
||||
|
||||
public static Expression<Func<T, bool>> Or<T>(this Expression<Func<T, bool>> left, Expression<Func<T, bool>> right)
|
||||
{
|
||||
InvocationExpression invokedExpr = Expression.Invoke(right, left.Parameters);
|
||||
return Expression.Lambda<Func<T, bool>>(Expression.OrElse(left.Body, invokedExpr), left.Parameters);
|
||||
}
|
||||
|
||||
public static Expression<Func<T, bool>> And<T>(this Expression<Func<T, bool>> left, Expression<Func<T, bool>> right)
|
||||
{
|
||||
InvocationExpression invokedExpr = Expression.Invoke(right, left.Parameters);
|
||||
return Expression.Lambda<Func<T, bool>>(Expression.AndAlso(left.Body, invokedExpr), left.Parameters);
|
||||
}
|
||||
}
|
||||
@@ -12,6 +12,7 @@ public static class KeyValuePairExtensions
|
||||
/// Implements key/value pair deconstruction.
|
||||
/// </summary>
|
||||
/// <remarks>Allows for <c>foreach ((var k, var v) in ...)</c>.</remarks>
|
||||
[Obsolete("Please replace uses of this extension method with native language features. This method will be removed in Umbraco 17.")]
|
||||
public static void Deconstruct<TKey, TValue>(this KeyValuePair<TKey, TValue> kvp, out TKey key, out TValue value)
|
||||
{
|
||||
key = kvp.Key;
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace Umbraco.Extensions;
|
||||
|
||||
public static class NameValueCollectionExtensions
|
||||
{
|
||||
[Obsolete("This method is no longer used in Umbraco. The method will be removed in Umbraco 17.")]
|
||||
public static IEnumerable<KeyValuePair<string?, string?>> AsEnumerable(this NameValueCollection nvc)
|
||||
{
|
||||
foreach (var key in nvc.AllKeys)
|
||||
@@ -16,9 +17,11 @@ public static class NameValueCollectionExtensions
|
||||
}
|
||||
}
|
||||
|
||||
[Obsolete("This method is no longer used in Umbraco. The method will be removed in Umbraco 17.")]
|
||||
public static bool ContainsKey(this NameValueCollection collection, string key) =>
|
||||
collection.Keys.Cast<object>().Any(k => (string)k == key);
|
||||
|
||||
[Obsolete("This method is no longer used in Umbraco. The method will be removed in Umbraco 17.")]
|
||||
public static T? GetValue<T>(this NameValueCollection collection, string key, T defaultIfNotFound)
|
||||
{
|
||||
if (collection.ContainsKey(key) == false)
|
||||
|
||||
@@ -44,6 +44,7 @@ public static class ObjectExtensions
|
||||
/// Disposes the object if it implements <see cref="IDisposable" />.
|
||||
/// </summary>
|
||||
/// <param name="input">The object.</param>
|
||||
[Obsolete("Please replace uses of this extension method with (input as IDisposable)?.Dispose(). This extension method will be removed in Umbraco 17.")]
|
||||
public static void DisposeIfDisposable(this object input)
|
||||
{
|
||||
if (input is IDisposable disposable)
|
||||
@@ -66,6 +67,7 @@ public static class ObjectExtensions
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <param name="input">The input.</param>
|
||||
/// <returns></returns>
|
||||
[Obsolete("This extension method is not longer used and will be removed in Umbraco 17.")]
|
||||
public static T? SafeCast<T>(this object input)
|
||||
{
|
||||
if (ReferenceEquals(null, input) || ReferenceEquals(default(T), input))
|
||||
@@ -353,6 +355,7 @@ public static class ObjectExtensions
|
||||
/// <param name="o"></param>
|
||||
/// <param name="ignoreProperties"></param>
|
||||
/// <returns></returns>
|
||||
[Obsolete("This method is no longer used in Umbraco. The method will be removed in Umbraco 17.")]
|
||||
public static IDictionary<string, TVal>? ToDictionary<T, TProperty, TVal>(
|
||||
this T o,
|
||||
params Expression<Func<T, TProperty>>[] ignoreProperties) => o?.ToDictionary<TVal>(ignoreProperties
|
||||
@@ -532,6 +535,7 @@ public static class ObjectExtensions
|
||||
/// <param name="o"></param>
|
||||
/// <param name="ignoreProperties">Properties to ignore</param>
|
||||
/// <returns></returns>
|
||||
[Obsolete("Use of this can be replaced with RouteValueDictionary or HtmlHelper.AnonymousObjectToHtmlAttributes(). The method will be removed in Umbraco 17.")]
|
||||
public static IDictionary<string, TVal> ToDictionary<TVal>(this object o, params string[] ignoreProperties)
|
||||
{
|
||||
if (o != null)
|
||||
|
||||
@@ -3298,6 +3298,7 @@ public static class PublishedContentExtensions
|
||||
/// </param>
|
||||
/// <param name="publishedCache"></param>
|
||||
/// <returns>The children of the content.</returns>
|
||||
[Obsolete("This method is no longer used in Umbraco. The method will be removed in Umbraco 17.")]
|
||||
public static DataTable ChildrenAsTable(
|
||||
this IPublishedContent content,
|
||||
IVariationContextAccessor variationContextAccessor,
|
||||
@@ -3640,6 +3641,7 @@ public static class PublishedContentExtensions
|
||||
where T : class, IPublishedContent =>
|
||||
Children<T>(content, variationContextAccessor, StaticServiceProvider.Instance.GetRequiredService<IPublishStatusQueryService>(), culture);
|
||||
|
||||
[Obsolete("This method is no longer used in Umbraco. The method will be removed in Umbraco 17.")]
|
||||
public static DataTable ChildrenAsTable(
|
||||
this IPublishedContent content,
|
||||
IVariationContextAccessor variationContextAccessor,
|
||||
|
||||
@@ -7,6 +7,7 @@ namespace Umbraco.Extensions;
|
||||
|
||||
public static class ThreadExtensions
|
||||
{
|
||||
[Obsolete("This method is no longer used in Umbraco. The method will be removed in Umbraco 17.")]
|
||||
public static void SanitizeThreadCulture(this Thread thread)
|
||||
{
|
||||
// get the current culture
|
||||
|
||||
@@ -669,6 +669,7 @@ public static class FriendlyPublishedContentExtensions
|
||||
/// null)
|
||||
/// </param>
|
||||
/// <returns>The children of the content.</returns>
|
||||
[Obsolete("This method is no longer used in Umbraco. The method will be removed in Umbraco 17.")]
|
||||
public static DataTable ChildrenAsTable(this IPublishedContent content, string contentTypeAliasFilter = "", string? culture = null)
|
||||
=>
|
||||
content.ChildrenAsTable(
|
||||
|
||||
Reference in New Issue
Block a user