Skip to content
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

Reintroduced a lot of extension methods as obsolete to avoid breaking change #17201

Conversation

bergmania
Copy link
Member

@bergmania bergmania commented Oct 7, 2024

Description

Reintroduces the extensions that is possible on PublishedContentExtensions, but as obsolete.

To avoid unnecessary breaking changes

Appendix

I tested with the following render controller and a doc type called Root.

using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ViewEngines;
using Umbraco.Cms.Core.Models.PublishedContent;
using Umbraco.Cms.Core.Routing;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Core.Web;
using Umbraco.Cms.Web.Common.Controllers;

namespace Umbraco.Cms.Web.UI;


public class RootController : RenderController
{
    private readonly IVariationContextAccessor _variationContextAccessor;
    private readonly IContentTypeService _contentTypeService;
    private readonly IMediaTypeService _mediaTypeService;
    private readonly IMemberTypeService _memberTypeService;
    private readonly IPublishedUrlProvider _publishedUrlProvider;

    public RootController(
        ILogger<RootController> logger,
        ICompositeViewEngine compositeViewEngine,
        IUmbracoContextAccessor umbracoContextAccessor,
        IVariationContextAccessor variationContextAccessor,
        IContentTypeService contentTypeService,
        IMediaTypeService mediaTypeService,
        IMemberTypeService memberTypeService,
        IPublishedUrlProvider publishedUrlProvider)
        : base(logger, compositeViewEngine, umbracoContextAccessor)
    {
        _variationContextAccessor = variationContextAccessor;
        _contentTypeService = contentTypeService;
        _mediaTypeService = mediaTypeService;
        _memberTypeService = memberTypeService;
        _publishedUrlProvider = publishedUrlProvider;
    }

    public override IActionResult Index()
    {
        if (CurrentPage is null)
        {
            return NotFound();
        }
#pragma warning disable CS0618 // Type or member is obsolete
        _ = CurrentPage.Ancestor();
        _ = CurrentPage.Ancestor(1);
        _ = CurrentPage.Ancestor("root");
        _ = CurrentPage.Ancestor<IPublishedContent>();
        _ = CurrentPage.Ancestor<IPublishedContent>(1);
        _ = CurrentPage.AncestorOrSelf();
        _ = CurrentPage.AncestorOrSelf(1);
        _ = CurrentPage.AncestorOrSelf("root");
        _ = CurrentPage.AncestorOrSelf<IPublishedContent>();
        _ = CurrentPage.AncestorOrSelf<IPublishedContent>(1);
        _ = CurrentPage.Ancestors();
        _ = CurrentPage.Ancestors(1);
        _ = CurrentPage.Ancestors("root");
        _ = CurrentPage.Ancestors<IPublishedContent>();
        _ = CurrentPage.Ancestors<IPublishedContent>(1);
        _ = CurrentPage.AncestorsOrSelf();
        _ = CurrentPage.AncestorsOrSelf(1);
        _ = CurrentPage.AncestorsOrSelf("root");
        _ = CurrentPage.AncestorsOrSelf(true, content => true);
        _ = CurrentPage.AncestorsOrSelf<IPublishedContent>();
        _ = CurrentPage.AncestorsOrSelf<IPublishedContent>(1);
        _ = CurrentPage.Breadcrumbs();
        _ = CurrentPage.Breadcrumbs(false);
        _ = CurrentPage.Breadcrumbs(1);
        _ = CurrentPage.Breadcrumbs(1, false);
        _ = CurrentPage.Breadcrumbs<IPublishedContent>();
        _ = CurrentPage.Breadcrumbs<IPublishedContent>(false);
        _ = CurrentPage.Children(_variationContextAccessor, "da");
        _ = CurrentPage.Children(_variationContextAccessor, content => true, "da");
        _ = CurrentPage.Children<IPublishedContent>(_variationContextAccessor, "da");
        _ = CurrentPage.ChildrenOfType(_variationContextAccessor, "root", "da");
        _ = CurrentPage.ChildrenAsTable(_variationContextAccessor, _contentTypeService, _mediaTypeService, _memberTypeService, _publishedUrlProvider);
        _ = CurrentPage.DescendantsOrSelfOfType(_variationContextAccessor, "root", "da");
        _ = CurrentPage.Children().DescendantsOrSelfOfType(_variationContextAccessor, "root", "da");
        _ = CurrentPage.Children().DescendantsOrSelf<IPublishedContent>(_variationContextAccessor, "da");
        _ = CurrentPage.Descendants(_variationContextAccessor, "da");
        _ = CurrentPage.Descendants(_variationContextAccessor, 1,"da");
        _ = CurrentPage.DescendantsOfType(_variationContextAccessor, "root", "da");
        _ = CurrentPage.DescendantsOfType(_variationContextAccessor, "root", "da");
        _ = CurrentPage.Descendants<IPublishedContent>(_variationContextAccessor, "da");
        _ = CurrentPage.Descendants<IPublishedContent>(_variationContextAccessor, 1,"da");
        _ = CurrentPage.DescendantsOrSelf(_variationContextAccessor, "da");
        _ = CurrentPage.DescendantsOrSelf(_variationContextAccessor, 1,"da");
        _ = CurrentPage.DescendantsOrSelfOfType(_variationContextAccessor, "root", "da");
        _ = CurrentPage.DescendantsOrSelfOfType(_variationContextAccessor, "root", "da");
        _ = CurrentPage.DescendantsOrSelf<IPublishedContent>(_variationContextAccessor, "da");
        _ = CurrentPage.DescendantsOrSelf<IPublishedContent>(_variationContextAccessor, 1,"da");
        _ = CurrentPage.Descendant(_variationContextAccessor, "da");
        _ = CurrentPage.Descendant(_variationContextAccessor, 1,"da");
        _ = CurrentPage.DescendantOfType(_variationContextAccessor, "root", "da");
        _ = CurrentPage.DescendantOfType(_variationContextAccessor, "root", "da");
        _ = CurrentPage.Descendant<IPublishedContent>(_variationContextAccessor, "da");
        _ = CurrentPage.Descendant<IPublishedContent>(_variationContextAccessor, 1,"da");
        _ = CurrentPage.DescendantOrSelf(_variationContextAccessor, "da");
        _ = CurrentPage.DescendantOrSelf(_variationContextAccessor, 1,"da");
        _ = CurrentPage.DescendantOrSelfOfType(_variationContextAccessor, "root", "da");
        _ = CurrentPage.DescendantOrSelfOfType(_variationContextAccessor, "root", "da");
        _ = CurrentPage.DescendantOrSelf<IPublishedContent>(_variationContextAccessor, "da");
        _ = CurrentPage.DescendantOrSelf<IPublishedContent>(_variationContextAccessor, 1,"da");
        _ = CurrentPage.FirstChild(_variationContextAccessor,"da");
        _ = CurrentPage.FirstChildOfType(_variationContextAccessor, "root","da");
        _ = CurrentPage.FirstChild<IPublishedContent>(_variationContextAccessor);
        _ = CurrentPage.FirstChild<IPublishedContent>(_variationContextAccessor, content => true);
        _ = CurrentPage.Parent<IPublishedContent>();
        _ = CurrentPage.Root();
        _ = CurrentPage.Root<IPublishedContent>();
        _ = CurrentPage.Siblings(_variationContextAccessor, "da");
        _ = CurrentPage.Siblings<IPublishedContent>(_variationContextAccessor, "da");
        _ = CurrentPage.SiblingsOfType(_variationContextAccessor, "root", "da");
        _ = CurrentPage.SiblingsAndSelf(_variationContextAccessor, "da");
        _ = CurrentPage.SiblingsAndSelf<IPublishedContent>(_variationContextAccessor, "da");
        _ = CurrentPage.SiblingsAndSelfOfType(_variationContextAccessor, "root", "da");
#pragma warning restore CS0618 // Type or member is obsolete

        // return a 'model' to the selected template/view for this page.
        return CurrentTemplate(CurrentPage);
    }
}

@bergmania bergmania merged commit a73fef1 into release/15.0 Oct 8, 2024
14 of 15 checks passed
@bergmania bergmania deleted the v15/hotfix/reintroduce-extentionsmethods-as-obsolete-to-avoid-breaking-changes branch October 8, 2024 12:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants