From efbad23e03beb2e7721ef594739f3283c5330fbb Mon Sep 17 00:00:00 2001 From: Johan Petersson Date: Wed, 22 Nov 2023 10:16:53 +0100 Subject: [PATCH] Fixes some warnings --- templates/Alloy.Mvc/Business/ContentLocator.cs | 2 +- .../Business/Rendering/AlloyContentAreaItemRenderer.cs | 2 +- templates/Alloy.Mvc/Components/ContactBlockViewComponent.cs | 2 +- .../Alloy.Mvc/Components/PageListBlockViewComponent.cs | 6 +++--- templates/EPiServer.Templates.csproj | 4 +++- 5 files changed, 9 insertions(+), 7 deletions(-) diff --git a/templates/Alloy.Mvc/Business/ContentLocator.cs b/templates/Alloy.Mvc/Business/ContentLocator.cs index 329f07d..30fe4fa 100644 --- a/templates/Alloy.Mvc/Business/ContentLocator.cs +++ b/templates/Alloy.Mvc/Business/ContentLocator.cs @@ -60,7 +60,7 @@ public IEnumerable FindPagesByPageType(PageReference pageLink, bool re } // Type specified through page type ID - private IEnumerable FindPagesByPageTypeRecursively(PageReference pageLink, int pageTypeId) + private PageDataCollection FindPagesByPageTypeRecursively(PageReference pageLink, int pageTypeId) { var criteria = new PropertyCriteriaCollection { diff --git a/templates/Alloy.Mvc/Business/Rendering/AlloyContentAreaItemRenderer.cs b/templates/Alloy.Mvc/Business/Rendering/AlloyContentAreaItemRenderer.cs index 54fd9ba..a9e201b 100644 --- a/templates/Alloy.Mvc/Business/Rendering/AlloyContentAreaItemRenderer.cs +++ b/templates/Alloy.Mvc/Business/Rendering/AlloyContentAreaItemRenderer.cs @@ -38,7 +38,7 @@ private static string GetCssClassForTag(string tagName) private static string GetTypeSpecificCssClasses(ContentAreaItem contentAreaItem) { - var content = contentAreaItem.GetContent(); + var content = contentAreaItem.LoadContent(); var cssClass = content == null ? string.Empty : content.GetOriginalType().Name.ToLowerInvariant(); if (content is ICustomCssInContentArea customClassContent && diff --git a/templates/Alloy.Mvc/Components/ContactBlockViewComponent.cs b/templates/Alloy.Mvc/Components/ContactBlockViewComponent.cs index 4f00f68..e511f23 100644 --- a/templates/Alloy.Mvc/Components/ContactBlockViewComponent.cs +++ b/templates/Alloy.Mvc/Components/ContactBlockViewComponent.cs @@ -51,7 +51,7 @@ protected override IViewComponentResult InvokeComponent(ContactBlock currentCont return View(model); } - private IHtmlContent GetLinkUrl(ContactBlock contactBlock) + private HtmlString GetLinkUrl(ContactBlock contactBlock) { if (contactBlock.LinkUrl != null && !contactBlock.LinkUrl.IsEmpty()) { diff --git a/templates/Alloy.Mvc/Components/PageListBlockViewComponent.cs b/templates/Alloy.Mvc/Components/PageListBlockViewComponent.cs index 454088e..5d3471d 100644 --- a/templates/Alloy.Mvc/Components/PageListBlockViewComponent.cs +++ b/templates/Alloy.Mvc/Components/PageListBlockViewComponent.cs @@ -47,7 +47,7 @@ private IEnumerable FindPages(PageListBlock currentBlock) if (currentBlock.Recursive) { - if (currentBlock.PageTypeFilter != null) + if (currentBlock.PageTypeFilter is not null) { pages = _contentLocator.FindPagesByPageType(listRoot, true, currentBlock.PageTypeFilter.ID); } @@ -58,7 +58,7 @@ private IEnumerable FindPages(PageListBlock currentBlock) } else { - if (currentBlock.PageTypeFilter != null) + if (currentBlock.PageTypeFilter is not null) { pages = _contentLoader .GetChildren(listRoot) @@ -70,7 +70,7 @@ private IEnumerable FindPages(PageListBlock currentBlock) } } - if (currentBlock.CategoryFilter != null && currentBlock.CategoryFilter.Any()) + if (currentBlock.CategoryFilter is not null && !currentBlock.CategoryFilter.IsEmpty) { pages = pages.Where(x => x.Category.Intersect(currentBlock.CategoryFilter).Any()); } diff --git a/templates/EPiServer.Templates.csproj b/templates/EPiServer.Templates.csproj index eacb05a..70e0da6 100644 --- a/templates/EPiServer.Templates.csproj +++ b/templates/EPiServer.Templates.csproj @@ -8,7 +8,9 @@ content true - $(NoWarn);NU5100;NU5110;NU5111;NU5123 + + + $(NoWarn);NU5100;NU5110;NU5111;NU5123;CA1707;IDE0005