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

Updates to .NET8 #48

Merged
merged 11 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
<Project>
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>9.0</LangVersion>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<IsPackable>false</IsPackable>
<IncludeSymbols>false</IncludeSymbols>
<WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject>
<!-- CA1707: Removes warning about underscores in namespaces -->
<NoWarn>$(NoWarn); CA1707</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<!-- CA1707: Identifiers should not contain underscores -->
<!-- CS1591: Missing XML comments -->
<!-- IDE0005: Using directive is unnecessary -->
<NoWarn>$(NoWarn);CA1707;CS1591;IDE0005</NoWarn>
</PropertyGroup>

<PropertyGroup>
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

[![Continuous integration](https://github.com/episerver/content-templates/actions/workflows/ci.yml/badge.svg)](https://github.com/episerver/content-templates/actions/workflows/ci.yml)

This repository contains templates for Optimizely Digital Experience Cloud to be used with `dotnet new` and Visual Studio 2022.
This repository contains templates for Optimizely Digital Experience Cloud to be used with `dotnet new` and Visual Studio 17.8.0+.
JohanPetersson marked this conversation as resolved.
Show resolved Hide resolved

The templates in this repository are distributed as a NuGet package available from [NuGet.org](https://www.nuget.org/packages/EPiServer.Templates/) and can be installed using the `dotnet new` command.

```bash
$ dotnet new -i EPiServer.Templates
```

Once installed, these templates will also be available in Visual Studio 2022.
Once installed, these templates will also be available in Visual Studio 17.8.0+.
Note that Visual Studio currently only supports *Project Templates* and not *Item Templates*.

To generate code based on the template simply execute the following.
Expand Down
2 changes: 1 addition & 1 deletion build/version.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- This file may be overwritten by automation. Only values allowed here are VersionPrefix and VersionSuffix. -->
<Project>
<PropertyGroup>
<VersionPrefix>1.6.0</VersionPrefix>
<VersionPrefix>1.7.0</VersionPrefix>
<VersionSuffix Condition="'$(Configuration)' == 'Debug'">devbuild</VersionSuffix>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "6.0.100",
"version": "8.0.100",
"runtime": "clr",
"architecture": "x86",
"rollForward": "minor"
Expand Down
6 changes: 3 additions & 3 deletions templates/Alloy.Mvc/Alloy.Mvc.1.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>disable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand All @@ -13,8 +13,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="EPiServer.CMS" Version="12.18.0" />
<PackageReference Include="Wangkanai.Detection" Version="5.2.0" />
<PackageReference Include="EPiServer.CMS" Version="12.25.1" />
<PackageReference Include="Wangkanai.Detection" Version="8.7.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Binary file modified templates/Alloy.Mvc/App_Data/Alloy.Mvc.1.mdf
Binary file not shown.
2 changes: 1 addition & 1 deletion templates/Alloy.Mvc/Business/ContentLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public IEnumerable<PageData> FindPagesByPageType(PageReference pageLink, bool re
}

// Type specified through page type ID
private IEnumerable<PageData> FindPagesByPageTypeRecursively(PageReference pageLink, int pageTypeId)
private PageDataCollection FindPagesByPageTypeRecursively(PageReference pageLink, int pageTypeId)
{
var criteria = new PropertyCriteriaCollection
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using EPiServer.ServiceLocation;
using EPiServer.Web;
using EPiServer.Web.Mvc;
using EPiServer.Web.Mvc.Html;

namespace Alloy.Mvc._1.Business.Initialization;

Expand Down
6 changes: 2 additions & 4 deletions templates/Alloy.Mvc/Business/PageContextActionFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ namespace Alloy.Mvc._1.Business;
public class PageContextActionFilter : IResultFilter
{
private readonly PageViewContextFactory _contextFactory;

public PageContextActionFilter(PageViewContextFactory contextFactory)
{
_contextFactory = contextFactory;
Expand All @@ -41,10 +42,7 @@ public void OnResultExecuting(ResultExecutingContext context)

model.Layout = layoutModel;

if (model.Section == null)
{
model.Section = _contextFactory.GetSection(currentContentLink);
}
model.Section ??= _contextFactory.GetSection(currentContentLink);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ namespace Alloy.Mvc._1.Business.Rendering;

public class SiteViewEngineLocationExpander : IViewLocationExpander
{
private static readonly string[] AdditionalPartialViewFormats = new[]
{
private static readonly string[] AdditionalPartialViewFormats =
[
TemplateCoordinator.BlockFolder + "{0}.cshtml",
TemplateCoordinator.PagePartialsFolder + "{0}.cshtml"
};
];

public IEnumerable<string> ExpandViewLocations(ViewLocationExpanderContext context, IEnumerable<string> viewLocations)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using EPiServer.ServiceLocation;
using Alloy.Mvc._1.Controllers;
using Alloy.Mvc._1.Models.Blocks;
using Alloy.Mvc._1.Models.Pages;
using EPiServer.ServiceLocation;
using EPiServer.Web;
using EPiServer.Web.Mvc;

Expand Down Expand Up @@ -40,7 +40,7 @@ public void Register(TemplateModelCollection viewTemplateModelRegistrator)
viewTemplateModelRegistrator.Add(typeof(TeaserBlock), new TemplateModel
{
Name = "TeaserBlockWide",
Tags = new[] { Globals.ContentAreaTags.WideWidth, Globals.ContentAreaTags.FullWidth },
Tags = [Globals.ContentAreaTags.WideWidth, Globals.ContentAreaTags.FullWidth],
AvailableWithoutTag = false,
});

Expand All @@ -56,7 +56,7 @@ public void Register(TemplateModelCollection viewTemplateModelRegistrator)
{
Name = "PageWide",
Inherit = true,
Tags = new[] { Globals.ContentAreaTags.WideWidth, Globals.ContentAreaTags.FullWidth },
Tags = [Globals.ContentAreaTags.WideWidth, Globals.ContentAreaTags.FullWidth],
AvailableWithoutTag = false,
Path = PagePartialPath("PageWide.cshtml")
});
Expand All @@ -65,7 +65,7 @@ public void Register(TemplateModelCollection viewTemplateModelRegistrator)
{
Name = "NoRenderer",
Inherit = true,
Tags = new[] { Globals.ContentAreaTags.NoRenderer },
Tags = [Globals.ContentAreaTags.NoRenderer],
AvailableWithoutTag = false,
Path = BlockPath("NoRenderer.cshtml")
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using EPiServer.Shell;
using Alloy.Mvc._1.Models.Pages;
using EPiServer.Shell;

namespace Alloy.Mvc._1.Business.UIDescriptors;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private IEnumerable<PageData> FindPages(PageListBlock currentBlock)

if (currentBlock.Recursive)
{
if (currentBlock.PageTypeFilter != null)
if (currentBlock.PageTypeFilter is not null)
{
pages = _contentLocator.FindPagesByPageType(listRoot, true, currentBlock.PageTypeFilter.ID);
}
Expand All @@ -58,7 +58,7 @@ private IEnumerable<PageData> FindPages(PageListBlock currentBlock)
}
else
{
if (currentBlock.PageTypeFilter != null)
if (currentBlock.PageTypeFilter is not null)
{
pages = _contentLoader
.GetChildren<PageData>(listRoot)
Expand All @@ -70,7 +70,7 @@ private IEnumerable<PageData> 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());
}
Expand Down
2 changes: 1 addition & 1 deletion templates/Alloy.Mvc/Controllers/DefaultPageController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using EPiServer.Framework.DataAnnotations;
using Alloy.Mvc._1.Models.Pages;
using Alloy.Mvc._1.Models.ViewModels;
using EPiServer.Framework.DataAnnotations;
using Microsoft.AspNetCore.Mvc;

namespace Alloy.Mvc._1.Controllers;
Expand Down
2 changes: 1 addition & 1 deletion templates/Alloy.Mvc/Controllers/PreviewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Alloy.Mvc._1.Controllers;
[TemplateDescriptor(
Inherited = true,
TemplateTypeCategory = TemplateTypeCategories.MvcController, //Required as controllers for blocks are registered as MvcPartialController by default
Tags = new[] { RenderingTags.Preview, RenderingTags.Edit },
Tags = [RenderingTags.Preview, RenderingTags.Edit],
AvailableWithoutTag = false)]
[VisitorGroupImpersonation]
[RequireClientResources]
Expand Down
2 changes: 1 addition & 1 deletion templates/Alloy.Mvc/Extensions/ViewContextExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public static class ViewContextExtension
/// <param name="viewContext"></param>
/// <returns></returns>
public static bool IsPreviewMode(this ViewContext viewContext)
=> viewContext.IsInEditMode() && (viewContext.ActionDescriptor as ControllerActionDescriptor)?.ControllerName == "Preview";
=> viewContext.IsInEditMode() && viewContext.ActionDescriptor is ControllerActionDescriptor { ControllerName: "Preview" };

/// <summary>
/// Determines if the request context is in edit mode.
Expand Down
4 changes: 2 additions & 2 deletions templates/Alloy.Mvc/Helpers/CategorizableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public static string[] GetThemeCssClassNames(this ICategorizable content)
{
if (content.Category == null)
{
return Array.Empty<string>();
return [];
}

// Although with some overhead, a HashSet allows us to ensure we never add a CSS class more than once
Expand All @@ -43,6 +43,6 @@ public static string[] GetThemeCssClassNames(this ICategorizable content)
}
}

return cssClasses.ToArray();
return [.. cssClasses];
}
}
1 change: 0 additions & 1 deletion templates/Alloy.Mvc/Helpers/UrlHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using EPiServer.ServiceLocation;
using EPiServer.Shell.Navigation;
using EPiServer.Web.Routing;
using Microsoft.AspNetCore.Mvc;

Expand Down
4 changes: 2 additions & 2 deletions templates/Alloy.Mvc/Models/Pages/ProductPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Alloy.Mvc._1.Models.Pages;
[SiteImageUrl(Globals.StaticGraphicsFolderPath + "page-type-thumbnail-product.png")]
[AvailableContentTypes(
Availability = Availability.Specific,
IncludeOn = new[] { typeof(StartPage) })]
IncludeOn = [typeof(StartPage)])]
public class ProductPage : StandardPage, IHasRelatedContent
{
[Required]
Expand All @@ -25,6 +25,6 @@ public class ProductPage : StandardPage, IHasRelatedContent
GroupName = SystemTabNames.Content,
Order = 330)]
[CultureSpecific]
[AllowedTypes(new[] { typeof(IContentData) }, new[] { typeof(JumbotronBlock) })]
[AllowedTypes([typeof(IContentData)], [typeof(JumbotronBlock)])]
public virtual ContentArea RelatedContentArea { get; set; }
}
2 changes: 1 addition & 1 deletion templates/Alloy.Mvc/Models/Pages/SearchPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ public class SearchPage : SitePageData, IHasRelatedContent, ISearchPage
GroupName = SystemTabNames.Content,
Order = 310)]
[CultureSpecific]
[AllowedTypes(new[] { typeof(IContentData) }, new[] { typeof(JumbotronBlock) })]
[AllowedTypes([typeof(IContentData)], [typeof(JumbotronBlock)])]
public virtual ContentArea RelatedContentArea { get; set; }
}
13 changes: 7 additions & 6 deletions templates/Alloy.Mvc/Models/Pages/StartPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,23 @@ namespace Alloy.Mvc._1.Models.Pages;
[SiteImageUrl]
[AvailableContentTypes(
Availability.Specific,
Include = new[]
{
Include =
[
typeof(ContainerPage),
typeof(ProductPage),
typeof(StandardPage),
typeof(ISearchPage),
typeof(LandingPage),
typeof(ContentFolder) }, // Pages we can create under the start page...
ExcludeOn = new[]
{
typeof(ContentFolder)
], // Pages we can create under the start page...
ExcludeOn =
[
typeof(ContainerPage),
typeof(ProductPage),
typeof(StandardPage),
typeof(ISearchPage),
typeof(LandingPage)
})] // ...and underneath those we can't create additional start pages
])] // ...and underneath those we can't create additional start pages
public class StartPage : SitePageData
{
[Display(
Expand Down
2 changes: 1 addition & 1 deletion templates/Alloy.Mvc/Models/ViewModels/PreviewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public PreviewModel(SitePageData currentPage, IContent previewContent)

public IContent PreviewContent { get; set; }

public List<PreviewArea> Areas { get; set; }
public List<PreviewArea> Areas { get; set; } = [];

public class PreviewArea
{
Expand Down
4 changes: 2 additions & 2 deletions templates/Alloy.Mvc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Chose one of the following options to get started.
### Windows

Prerequisities
- .NET SDK 6+
- .NET SDK 8+
- SQL Server 2016 Express LocalDB (or later)

```bash
Expand Down Expand Up @@ -38,7 +38,7 @@ $ docker-compose up
### Any OS with external database server

Prerequisities
- .NET SDK 6+
- .NET SDK 8+
- SQL Server 2016 (or later) on a external server, e.g. Azure SQL

Create an empty database on the external database server and update the connection string accordingly.
Expand Down
8 changes: 4 additions & 4 deletions templates/Alloy.Mvc/Views/Shared/Footer.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
<div class="row">
<div class="col-3">
<h3>@Html.Translate("/footer/products")</h3>
<div epi-property="@Model.Layout.ProductPages" />
<ul epi-property="@Model.Layout.ProductPages" />
</div>
<div class="col-3">
<h3>@Html.Translate("/footer/company")</h3>
<div epi-property="@Model.Layout.CompanyInformationPages" />
<ul epi-property="@Model.Layout.CompanyInformationPages" />
</div>
<div class="col-3">
<h3>@Html.Translate("/footer/news")</h3>
<div epi-property="@Model.Layout.NewsPages" />
<ul epi-property="@Model.Layout.NewsPages" />
</div>
<div class="col-3">
<h3>@Html.Translate("/footer/customerzone")</h3>
<div epi-property="@Model.Layout.CustomerZonePages" />
<ul epi-property="@Model.Layout.CustomerZonePages" />
<ul>
<li>
@if (Model.Layout.LoggedIn)
Expand Down
4 changes: 2 additions & 2 deletions templates/Cms.Empty/Cms.Empty.1.csproj
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
Expand All @@ -13,7 +13,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="EPiServer.CMS" Version="12.18.0" />
<PackageReference Include="EPiServer.CMS" Version="12.25.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading
Loading