Skip to content

Commit f8eee28

Browse files
committed
Changed to no longer persist component names for predicate registrations as its not supported by MetaData Editing
1 parent fa5202e commit f8eee28

6 files changed

Lines changed: 7 additions & 9 deletions

File tree

src/Sitecore.AspNetCore.SDK.Pages/Controllers/PagesSetupController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ private PagesConfigResponse BuildConfigResponseBody()
9191
return new PagesConfigResponse
9292
{
9393
EditMode = "metadata",
94-
Components = renderingEngineOptions.RendererRegistry.Select(x => x.Value.ComponentName).ToList()
94+
Components = renderingEngineOptions.RendererRegistry.Where(x => x.Value.ComponentName != string.Empty).Select(x => x.Value.ComponentName).ToList()
9595
};
9696
}
9797

src/Sitecore.AspNetCore.SDK.RenderingEngine/Extensions/RenderingEngineOptionsExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public static RenderingEngineOptions AddViewComponent(
151151
ArgumentNullException.ThrowIfNull(match);
152152
ArgumentException.ThrowIfNullOrWhiteSpace(viewComponentName);
153153

154-
ComponentRendererDescriptor descriptor = ViewComponentComponentRenderer.Describe(match, viewComponentName, viewComponentName);
154+
ComponentRendererDescriptor descriptor = ViewComponentComponentRenderer.Describe(match, viewComponentName);
155155

156156
options.RendererRegistry.Add(options.RendererRegistry.Count, descriptor);
157157

src/Sitecore.AspNetCore.SDK.RenderingEngine/Rendering/ComponentRendererDescriptor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88
/// </remarks>
99
/// <param name="match">The predicate to use when retrieving a <see cref="IComponentRenderer"/>.</param>
1010
/// <param name="factory">The factory method to create a new instance of the <see cref="IComponentRenderer"/>.</param>
11+
/// <param name="componentName">The name of the component being added.</param>
1112
public class ComponentRendererDescriptor(
1213
Predicate<string> match,
1314
Func<IServiceProvider, IComponentRenderer> factory,
14-
string componentName)
15+
string componentName = "")
1516
{
1617
private readonly Func<IServiceProvider, IComponentRenderer> _factory = factory ?? throw new ArgumentNullException(nameof(factory));
1718
private readonly object _lock = new();

src/Sitecore.AspNetCore.SDK.RenderingEngine/Rendering/LoggingComponentRenderer.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ public static ComponentRendererDescriptor Describe(Predicate<string> match)
3131

3232
return new ComponentRendererDescriptor(
3333
match,
34-
sp => ActivatorUtilities.CreateInstance<LoggingComponentRenderer>(sp),
35-
string.Empty);
34+
sp => ActivatorUtilities.CreateInstance<LoggingComponentRenderer>(sp));
3635
}
3736

3837
/// <inheritdoc />

src/Sitecore.AspNetCore.SDK.RenderingEngine/Rendering/PartialViewComponentRenderer.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ public static ComponentRendererDescriptor Describe(Predicate<string> match, stri
3535
ArgumentException.ThrowIfNullOrWhiteSpace(locator);
3636
return new ComponentRendererDescriptor(
3737
match,
38-
sp => ActivatorUtilities.CreateInstance<PartialViewComponentRenderer>(sp, locator),
39-
locator);
38+
sp => ActivatorUtilities.CreateInstance<PartialViewComponentRenderer>(sp, locator));
4039
}
4140

4241
/// <inheritdoc />

src/Sitecore.AspNetCore.SDK.RenderingEngine/Rendering/ViewComponentComponentRenderer.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ public ViewComponentComponentRenderer(string locator)
3131
/// <param name="locator">The string to use when locating the View Component.</param>
3232
/// <param name="componentName">The string to use describe the name of the components.</param>
3333
/// <returns>An instance of <see cref="ComponentRendererDescriptor"/>.</returns>
34-
public static ComponentRendererDescriptor Describe(Predicate<string> match, string locator, string componentName)
34+
public static ComponentRendererDescriptor Describe(Predicate<string> match, string locator, string componentName = "")
3535
{
3636
ArgumentNullException.ThrowIfNull(match);
3737
ArgumentException.ThrowIfNullOrWhiteSpace(locator);
38-
ArgumentException.ThrowIfNullOrWhiteSpace(componentName);
3938

4039
return new ComponentRendererDescriptor(
4140
match,

0 commit comments

Comments
 (0)