Skip to content

Commit

Permalink
Use ValueTask in INavigationProvider (#16650)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Sebastien Ros <[email protected]>
  • Loading branch information
MikeAlhayek and sebastienros authored Sep 3, 2024
1 parent 3242f90 commit 6a0ecfe
Show file tree
Hide file tree
Showing 70 changed files with 607 additions and 552 deletions.
6 changes: 3 additions & 3 deletions src/OrchardCore.Modules/OrchardCore.Admin/AdminMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public AdminMenu(IStringLocalizer<AdminMenu> localizer)
S = localizer;
}

public Task BuildNavigationAsync(string name, NavigationBuilder builder)
public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder)
{
if (!NavigationHelper.IsAdminMenu(name))
{
return Task.CompletedTask;
return ValueTask.CompletedTask;
}

builder
Expand All @@ -39,6 +39,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder)
)
);

return Task.CompletedTask;
return ValueTask.CompletedTask;
}
}
12 changes: 6 additions & 6 deletions src/OrchardCore.Modules/OrchardCore.AdminMenu/AdminMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@ namespace OrchardCore.AdminMenu;

public sealed class AdminMenu : INavigationProvider
{
private readonly AdminMenuNavigationProvidersCoordinator _adminMenuNavigationProvider;
private readonly AdminMenuNavigationProvidersCoordinator _adminMenuNavigationProviderCoordinator;

internal readonly IStringLocalizer S;

public AdminMenu(AdminMenuNavigationProvidersCoordinator adminMenuNavigationProvider,
public AdminMenu(AdminMenuNavigationProvidersCoordinator adminMenuNavigationProviderCoordinator,
IStringLocalizer<AdminMenu> localizer)
{
_adminMenuNavigationProvider = adminMenuNavigationProvider;
_adminMenuNavigationProviderCoordinator = adminMenuNavigationProviderCoordinator;
S = localizer;
}

public async Task BuildNavigationAsync(string name, NavigationBuilder builder)
public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder)
{
if (!NavigationHelper.IsAdminMenu(name))
{
return;
return ValueTask.CompletedTask;
}

// Configuration and settings menus for the AdminMenu module
Expand All @@ -35,6 +35,6 @@ public async Task BuildNavigationAsync(string name, NavigationBuilder builder)
);

// This is the entry point for the adminMenu: dynamically generated custom admin menus
await _adminMenuNavigationProvider.BuildNavigationAsync(NavigationConstants.AdminMenuId, builder);
return _adminMenuNavigationProviderCoordinator.BuildNavigationAsync(NavigationConstants.AdminMenuId, builder);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public AdminMenuNavigationProvidersCoordinator(
_logger = logger;
}

public async Task BuildNavigationAsync(string name, NavigationBuilder builder)
public async ValueTask BuildNavigationAsync(string name, NavigationBuilder builder)
{
// We only add them if the caller uses the string "adminMenu".
if (name != NavigationConstants.AdminMenuId)
Expand Down
6 changes: 3 additions & 3 deletions src/OrchardCore.Modules/OrchardCore.Apis.GraphQL/AdminMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ public AdminMenu(IStringLocalizer<AdminMenu> localizer)
S = localizer;
}

public Task BuildNavigationAsync(string name, NavigationBuilder builder)
public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder)
{
if (!NavigationHelper.IsAdminMenu(name))
{
return Task.CompletedTask;
return ValueTask.CompletedTask;
}

builder
Expand All @@ -28,6 +28,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder)
)
);

return Task.CompletedTask;
return ValueTask.CompletedTask;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public AuditTrailAdminMenu(IStringLocalizer<AuditTrailAdminMenu> stringLocalizer
S = stringLocalizer;
}

public Task BuildNavigationAsync(string name, NavigationBuilder builder)
public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder)
{
if (!NavigationHelper.IsAdminMenu(name))
{
return Task.CompletedTask;
return ValueTask.CompletedTask;
}

builder
Expand All @@ -36,6 +36,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder)
.LocalNav()
);

return Task.CompletedTask;
return ValueTask.CompletedTask;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ public AuditTrailSettingsAdminMenu(IStringLocalizer<AuditTrailSettingsAdminMenu>
S = stringLocalizer;
}

public Task BuildNavigationAsync(string name, NavigationBuilder builder)
public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder)
{
if (!NavigationHelper.IsAdminMenu(name))
{
return Task.CompletedTask;
return ValueTask.CompletedTask;
}

builder
Expand All @@ -40,6 +40,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder)
)
);

return Task.CompletedTask;
return ValueTask.CompletedTask;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ public sealed class AdminMenu : INavigationProvider

public AdminMenu(IStringLocalizer<AdminMenu> localizer) => S = localizer;

public Task BuildNavigationAsync(string name, NavigationBuilder builder)
public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder)
{
if (!NavigationHelper.IsAdminMenu(name))
{
return Task.CompletedTask;
return ValueTask.CompletedTask;
}

builder
Expand All @@ -27,6 +27,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder)
)
);

return Task.CompletedTask;
return ValueTask.CompletedTask;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ public AdminMenu(IStringLocalizer<AdminMenu> localizer)
S = localizer;
}

public Task BuildNavigationAsync(string name, NavigationBuilder builder)
public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder)
{
if (!NavigationHelper.IsAdminMenu(name))
{
return Task.CompletedTask;
return ValueTask.CompletedTask;
}

builder
Expand All @@ -55,6 +55,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder)
)
);

return Task.CompletedTask;
return ValueTask.CompletedTask;
}
}
6 changes: 3 additions & 3 deletions src/OrchardCore.Modules/OrchardCore.ContentTypes/AdminMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public AdminMenu(IStringLocalizer<AdminMenu> localizer)
S = localizer;
}

public Task BuildNavigationAsync(string name, NavigationBuilder builder)
public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder)
{
if (!NavigationHelper.IsAdminMenu(name))
{
return Task.CompletedTask;
return ValueTask.CompletedTask;
}

builder
Expand All @@ -39,6 +39,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder)
)
);

return Task.CompletedTask;
return ValueTask.CompletedTask;
}
}
2 changes: 1 addition & 1 deletion src/OrchardCore.Modules/OrchardCore.Contents/AdminMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public AdminMenu(
S = localizer;
}

public async Task BuildNavigationAsync(string name, NavigationBuilder builder)
public async ValueTask BuildNavigationAsync(string name, NavigationBuilder builder)
{
if (!NavigationHelper.IsAdminMenu(name))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ public ExportContentToDeploymentTargetAdminMenu(IStringLocalizer<AdminMenu> loca
S = localizer;
}

public Task BuildNavigationAsync(string name, NavigationBuilder builder)
public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder)
{
if (!NavigationHelper.IsAdminMenu(name))
{
return Task.CompletedTask;
return ValueTask.CompletedTask;
}

builder
Expand All @@ -39,6 +39,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder)
)
);

return Task.CompletedTask;
return ValueTask.CompletedTask;
}
}
6 changes: 3 additions & 3 deletions src/OrchardCore.Modules/OrchardCore.Cors/AdminMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ public AdminMenu(IStringLocalizer<AdminMenu> localizer)
S = localizer;
}

public Task BuildNavigationAsync(string name, NavigationBuilder builder)
public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder)
{
if (!NavigationHelper.IsAdminMenu(name))
{
return Task.CompletedTask;
return ValueTask.CompletedTask;
}

builder
Expand All @@ -32,6 +32,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder)
)
);

return Task.CompletedTask;
return ValueTask.CompletedTask;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public AdminMenu(
_customSettingsService = customSettingsService;
}

public async Task BuildNavigationAsync(string name, NavigationBuilder builder)
public async ValueTask BuildNavigationAsync(string name, NavigationBuilder builder)
{
if (!NavigationHelper.IsAdminMenu(name))
{
Expand Down
6 changes: 3 additions & 3 deletions src/OrchardCore.Modules/OrchardCore.Demo/AdminMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ public AdminMenu(IStringLocalizer<AdminMenu> localizer)
S = localizer;
}

public Task BuildNavigationAsync(string name, NavigationBuilder builder)
public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder)
{
if (!NavigationHelper.IsAdminMenu(name))
{
return Task.CompletedTask;
return ValueTask.CompletedTask;
}

builder
Expand Down Expand Up @@ -50,6 +50,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder)
)
);

return Task.CompletedTask;
return ValueTask.CompletedTask;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ public AdminMenu(IStringLocalizer<AdminMenu> localizer)
S = localizer;
}

public Task BuildNavigationAsync(string name, NavigationBuilder builder)
public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder)
{
if (!NavigationHelper.IsAdminMenu(name))
{
return Task.CompletedTask;
return ValueTask.CompletedTask;
}

builder
Expand All @@ -35,6 +35,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder)
)
);

return Task.CompletedTask;
return ValueTask.CompletedTask;
}
}
6 changes: 3 additions & 3 deletions src/OrchardCore.Modules/OrchardCore.Deployment/AdminMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ public AdminMenu(IStringLocalizer<AdminMenu> localizer)
S = localizer;
}

public Task BuildNavigationAsync(string name, NavigationBuilder builder)
public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder)
{
if (!NavigationHelper.IsAdminMenu(name))
{
return Task.CompletedTask;
return ValueTask.CompletedTask;
}

builder
Expand All @@ -40,6 +40,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder)
)
);

return Task.CompletedTask;
return ValueTask.CompletedTask;
}
}
6 changes: 3 additions & 3 deletions src/OrchardCore.Modules/OrchardCore.Email/AdminMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ public AdminMenu(IStringLocalizer<AdminMenu> localizer)
S = localizer;
}

public Task BuildNavigationAsync(string name, NavigationBuilder builder)
public ValueTask BuildNavigationAsync(string name, NavigationBuilder builder)
{
if (!NavigationHelper.IsAdminMenu(name))
{
return Task.CompletedTask;
return ValueTask.CompletedTask;
}

builder
Expand All @@ -49,6 +49,6 @@ public Task BuildNavigationAsync(string name, NavigationBuilder builder)
)
);

return Task.CompletedTask;
return ValueTask.CompletedTask;
}
}
Loading

0 comments on commit 6a0ecfe

Please sign in to comment.