Search code examples
aspnetboilerplate

MenuItemDefinition property "requiredPermissionName" is missing from 5.2.0 release (and pre-release)


There seems to be a breaking change in the latest release (5.2.0)

To replicate:

  1. download the latest stable template for mvc core
  2. Update all nuget packages to latest stable

The property requiredPermissionName is no longer available

Any steps to overcome would be appreciated...

Sample Code from Template (.net core MVC)

public class GpNavigationProvider : NavigationProvider
{
    public override void SetNavigation(INavigationProviderContext context)
    {
        context.Manager.MainMenu
            .AddItem(
                new MenuItemDefinition(
                    PageNames.Home,
                    L("HomePage"),
                    url: "",
                    icon: "home",
                    requiresAuthentication: true
                )
            ).AddItem(
                new MenuItemDefinition(
                    PageNames.Tenants,
                    L("Tenants"),
                    url: "Tenants",
                    icon: "business",
                    requiredPermissionName: PermissionNames.Pages_Tenants
                )

Compile Error:

Severity Code Description Project File Line Suppression State Error CS1739
The best overload for 'MenuItemDefinition' does not have a parameter named 'requiredPermissionName'
...\5.1.1\aspnet-core\src\Gp.Web.Mvc\Startup\GpNavigationProvider.cs 29 Active


Solution

  • The change is straightforward:

    // requiredPermissionName: PermissionNames.Pages_Tenants,
    permissionDependency: new SimplePermissionDependency(PermissionNames.Pages_Tenants),
    

    requiredPermissionName was deprecated in version 2.2 in July 2017.

    It was removed in version 5.2 that was released yesterday, after 3 major versions and more than 2.5 years.

    References: