V12: Deprecate XPath (#14372)

* Deprecate all outward facing methods that uses XPath

* Add more obsolete messages

---------

Co-authored-by: Zeegaan <nge@umbraco.dk>
This commit is contained in:
Nikolaj Geisle
2023-07-07 11:12:04 +02:00
committed by GitHub
parent 16c78b76dd
commit d116366b28
41 changed files with 97 additions and 0 deletions

View File

@@ -102,6 +102,7 @@ public interface IPublishedCache : IXPathNavigable
/// <param name="vars">Optional XPath variables.</param>
/// <returns>The content, or null.</returns>
/// <remarks>The value of <paramref name="preview" /> overrides defaults.</remarks>
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
IPublishedContent? GetSingleByXPath(bool preview, string xpath, params XPathVariable[] vars);
/// <summary>
@@ -111,6 +112,7 @@ public interface IPublishedCache : IXPathNavigable
/// <param name="vars">Optional XPath variables.</param>
/// <returns>The content, or null.</returns>
/// <remarks>Considers published or unpublished content depending on defaults.</remarks>
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
IPublishedContent? GetSingleByXPath(string xpath, params XPathVariable[] vars);
/// <summary>
@@ -121,6 +123,7 @@ public interface IPublishedCache : IXPathNavigable
/// <param name="vars">Optional XPath variables.</param>
/// <returns>The content, or null.</returns>
/// <remarks>The value of <paramref name="preview" /> overrides defaults.</remarks>
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
IPublishedContent? GetSingleByXPath(bool preview, XPathExpression xpath, params XPathVariable[] vars);
/// <summary>
@@ -130,6 +133,7 @@ public interface IPublishedCache : IXPathNavigable
/// <param name="vars">Optional XPath variables.</param>
/// <returns>The content, or null.</returns>
/// <remarks>Considers published or unpublished content depending on defaults.</remarks>
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
IPublishedContent? GetSingleByXPath(XPathExpression xpath, params XPathVariable[] vars);
/// <summary>
@@ -140,6 +144,7 @@ public interface IPublishedCache : IXPathNavigable
/// <param name="vars">Optional XPath variables.</param>
/// <returns>The contents.</returns>
/// <remarks>The value of <paramref name="preview" /> overrides defaults.</remarks>
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
IEnumerable<IPublishedContent> GetByXPath(bool preview, string xpath, params XPathVariable[] vars);
/// <summary>
@@ -149,6 +154,7 @@ public interface IPublishedCache : IXPathNavigable
/// <param name="vars">Optional XPath variables.</param>
/// <returns>The contents.</returns>
/// <remarks>Considers published or unpublished content depending on defaults.</remarks>
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
IEnumerable<IPublishedContent> GetByXPath(string xpath, params XPathVariable[] vars);
/// <summary>
@@ -159,6 +165,7 @@ public interface IPublishedCache : IXPathNavigable
/// <param name="vars">Optional XPath variables.</param>
/// <returns>The contents.</returns>
/// <remarks>The value of <paramref name="preview" /> overrides defaults.</remarks>
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
IEnumerable<IPublishedContent> GetByXPath(bool preview, XPathExpression xpath, params XPathVariable[] vars);
/// <summary>
@@ -168,6 +175,7 @@ public interface IPublishedCache : IXPathNavigable
/// <param name="vars">Optional XPath variables.</param>
/// <returns>The contents.</returns>
/// <remarks>Considers published or unpublished content depending on defaults.</remarks>
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
IEnumerable<IPublishedContent> GetByXPath(XPathExpression xpath, params XPathVariable[] vars);
/// <summary>
@@ -179,6 +187,7 @@ public interface IPublishedCache : IXPathNavigable
/// <para>The value of <paramref name="preview" /> overrides the context.</para>
/// <para>The navigator is already a safe clone (no need to clone it again).</para>
/// </remarks>
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
XPathNavigator CreateNavigator(bool preview);
/// <summary>
@@ -196,6 +205,7 @@ public interface IPublishedCache : IXPathNavigable
/// </para>
/// <para>If the node does not exist, returns null.</para>
/// </remarks>
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
XPathNavigator? CreateNodeNavigator(int id, bool preview);
/// <summary>

View File

@@ -38,20 +38,26 @@ public sealed class InternalPublishedContentCache : PublishedCacheBase, IPublish
public override IEnumerable<IPublishedContent> GetAtRoot(bool preview, string? culture = null) =>
_content.Values.Where(x => x.Parent == null);
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public override IPublishedContent GetSingleByXPath(bool preview, string xpath, XPathVariable[] vars) =>
throw new NotImplementedException();
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public override IPublishedContent GetSingleByXPath(bool preview, XPathExpression xpath, XPathVariable[] vars) =>
throw new NotImplementedException();
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public override IEnumerable<IPublishedContent> GetByXPath(bool preview, string xpath, XPathVariable[] vars) =>
throw new NotImplementedException();
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public override IEnumerable<IPublishedContent>
GetByXPath(bool preview, XPathExpression xpath, XPathVariable[] vars) => throw new NotImplementedException();
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public override XPathNavigator CreateNavigator(bool preview) => throw new NotImplementedException();
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public override XPathNavigator CreateNodeNavigator(int id, bool preview) => throw new NotImplementedException();
public override bool HasContent(bool preview) => _content.Count > 0;

View File

@@ -13,6 +13,7 @@ public class InternalPublishedProperty : IPublishedProperty
public bool SolidHasValue { get; set; }
[Obsolete("The current implementation of XPath is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public object? SolidXPathValue { get; set; }
public object? SolidDeliveryApiValue { get; set; }
@@ -25,6 +26,7 @@ public class InternalPublishedProperty : IPublishedProperty
public virtual object? GetValue(string? culture = null, string? segment = null) => SolidValue;
[Obsolete("The current implementation of XPath is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public virtual object? GetXPathValue(string? culture = null, string? segment = null) => SolidXPathValue;
public virtual object? GetDeliveryApiValue(bool expanding, string? culture = null, string? segment = null) => SolidDeliveryApiValue;

View File

@@ -40,31 +40,42 @@ public abstract class PublishedCacheBase : IPublishedCache
public IEnumerable<IPublishedContent> GetAtRoot(string? culture = null) => GetAtRoot(PreviewDefault, culture);
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public abstract IPublishedContent? GetSingleByXPath(bool preview, string xpath, XPathVariable[] vars);
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public IPublishedContent? GetSingleByXPath(string xpath, XPathVariable[] vars) =>
GetSingleByXPath(PreviewDefault, xpath, vars);
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public abstract IPublishedContent? GetSingleByXPath(bool preview, XPathExpression xpath, XPathVariable[] vars);
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public IPublishedContent? GetSingleByXPath(XPathExpression xpath, XPathVariable[] vars) =>
GetSingleByXPath(PreviewDefault, xpath, vars);
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public abstract IEnumerable<IPublishedContent> GetByXPath(bool preview, string xpath, XPathVariable[] vars);
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public IEnumerable<IPublishedContent> GetByXPath(string xpath, XPathVariable[] vars) =>
GetByXPath(PreviewDefault, xpath, vars);
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public abstract IEnumerable<IPublishedContent>
GetByXPath(bool preview, XPathExpression xpath, XPathVariable[] vars);
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public IEnumerable<IPublishedContent> GetByXPath(XPathExpression xpath, XPathVariable[] vars) =>
GetByXPath(PreviewDefault, xpath, vars);
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public abstract XPathNavigator CreateNavigator(bool preview);
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public XPathNavigator CreateNavigator() => CreateNavigator(PreviewDefault);
[Obsolete("The current implementation of this method is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public abstract XPathNavigator? CreateNodeNavigator(int id, bool preview);
public abstract bool HasContent(bool preview);

View File

@@ -201,6 +201,7 @@ internal class PublishedElementPropertyBase : PublishedPropertyBase
}
}
[Obsolete("The current implementation of XPath is suboptimal and will be removed entirely in a future version. Scheduled for removal in v14")]
public override object? GetXPathValue(string? culture = null, string? segment = null)
{
GetCacheLevels(out PropertyCacheLevel cacheLevel, out PropertyCacheLevel referenceCacheLevel);