Skip to content

Commit

Permalink
Added .net8.0 support.
Browse files Browse the repository at this point in the history
  • Loading branch information
svenrog committed Feb 7, 2024
1 parent 8f57a35 commit 82c5b18
Show file tree
Hide file tree
Showing 111 changed files with 4,146 additions and 4,207 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ csharp_style_inlined_variable_declaration=true:suggestion
csharp_style_throw_expression=true:suggestion
csharp_style_conditional_delegate_call=true:suggestion

# Except for primary constructors
csharp_style_prefer_primary_constructors = false

# Space preferences
csharp_space_after_cast=false
csharp_space_after_colon_in_inheritance_clause=true
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

All notable changes to this project will be documented in this file.

## [1.9.0]

### Added

- Added support for .NET 8

### Removed

- Removed support for .NET 5

## [1.8.3]

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion pack.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$outputDir = ".\.package\"
$version = "1.4.5"
$version = "1.9.0"

dotnet build --configuration Release /p:Version=$version
dotnet pack --configuration Release --output $outputDir /p:Version=$version --no-build
15 changes: 5 additions & 10 deletions sandbox/Alloy/AlloyMvcTemplates.csproj
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Import Project="..\dependencies.props" />
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BuildBundlerMinifier" Version="$(BuildBundlerMinifier)" />
<PackageReference Include="EPiServer.CMS" Version="12.7.0" />
<PackageReference Include="EPiServer.CMS.AspNetCore.HtmlHelpers" Version="12.7.0" />
<PackageReference Include="EPiServer.CMS.AspNetCore.Mvc" Version="12.7.0" />
<PackageReference Include="EPiServer.CMS.AspNetCore.Routing" Version="12.7.0" />
<PackageReference Include="EPiServer.CMS.AspNetCore.Templating" Version="12.7.0" />
<PackageReference Include="EPiServer.CMS" Version="12.24.0" />
<PackageReference Include="EPiServer.Commerce" Version="14.4.0" />
<PackageReference Include="EPiServer.ContentDeliveryApi.Cms" Version="3.3.0" />
<PackageReference Include="EPiServer.CMS.Core" Version="12.7.0" />
<PackageReference Include="EPiServer.Framework" Version="12.7.0" />
<PackageReference Include="EPiServer.Hosting" Version="12.7.0" />
<PackageReference Include="EPiServer.ContentDeliveryApi.Cms" Version="3.7.0" />
<PackageReference Include="EPiServer.Labs.LanguageManager" Version="5.2.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.14.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.3.0" />
<PackageReference Include="Wangkanai.Detection" Version="2.0.1" />
Expand Down
2 changes: 1 addition & 1 deletion sandbox/Alloy/Models/Pages/StartPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace AlloyMvcTemplates.Models.Pages
[SiteImageUrl]
[AvailableContentTypes(
Availability.Specific,
Include = new[] { typeof(ContainerPage), typeof(ProductPage), typeof(StandardPage), typeof(ISearchPage), typeof(LandingPage), typeof(ContentFolder) }, // Pages we can create under the start page...
Include = new[] { typeof(ContainerPage), typeof(ProductPage), typeof(StandardPage), typeof(ISearchPage), typeof(LandingPage), typeof(ContentFolder), typeof(AllPropertiesTestPage) }, // Pages we can create under the start page...
ExcludeOn = new[] { typeof(ContainerPage), typeof(ProductPage), typeof(StandardPage), typeof(ISearchPage), typeof(LandingPage) })] // ...and underneath those we can't create additional start pages
public class StartPage : SitePageData
{
Expand Down
2 changes: 2 additions & 0 deletions sandbox/Alloy/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using AlloyDependencies;
using AlloyMvcTemplates.Business.Initialization;
using AlloyMvcTemplates.Extensions;
using AlloyMvcTemplates.Infrastructure;
Expand Down Expand Up @@ -73,6 +74,7 @@ public void ConfigureServices(IServiceCollection services)
services.AddCommerce();
services.AddContentDeliveryApi();
services.AddGenericLinkConverters();
services.AddLinkDataExportTransform<ThumbnailLinkData>();

services.AddEmbeddedLocalization<Startup>();

Expand Down
Binary file modified sandbox/Alloy/modules/_protected/CMS/CMS.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified sandbox/Alloy/modules/_protected/Shell/Shell.zip
Binary file not shown.
7 changes: 5 additions & 2 deletions sandbox/AlloyDependencies/AllPropertiesTestPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,16 @@ public class AllPropertiesTestPage : PageData
public virtual string SelectionEditor2 { get; set; }

[CultureSpecific]
[Display(Name= "Thumbnail link collection", GroupName = SystemTabNames.Content, Order = 340)]
[Display(Name = "Thumbnail link collection", GroupName = SystemTabNames.Content, Order = 340)]
public virtual LinkDataCollection<ThumbnailLinkData> ThumbnailLinks { get; set; }

[Required]
[CultureSpecific]
[Display(Name = "Single thumbnail link", GroupName = SystemTabNames.Content, Order = 340)]
public virtual ThumbnailLinkData ThumbnailLink { get; set; }

[CultureSpecific]
[Display(Name = "Nested thumbnail links", GroupName = SystemTabNames.Content, Order = 340)]
public virtual IList<NestedLinkBlock> NestedThumbnailLinks { get; set; }
}

public class TestSelectionFactory : ISelectionFactory
Expand Down
3 changes: 2 additions & 1 deletion sandbox/AlloyDependencies/AlloyDependencies.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<IsPackable>false</IsPackable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

Expand Down
19 changes: 19 additions & 0 deletions sandbox/AlloyDependencies/NestedLinkBlock.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.ComponentModel.DataAnnotations;
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.DataAnnotations;
using Geta.Optimizely.GenericLinks;

namespace AlloyDependencies
{
[ContentType(GUID = "a523fc25-d6a4-4099-aaa2-10b182a15f73")]
public class NestedLinkBlock : BlockData
{
[CultureSpecific]
public virtual string Name { get; set; }

[CultureSpecific]
[Display(Name = "Thumbnail link collection", GroupName = SystemTabNames.Content, Order = 340)]
public virtual LinkDataCollection<ThumbnailLinkData> ThumbnailLinks { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
// Copyright (c) Geta Digital. All rights reserved.
// Licensed under Apache-2.0. See the LICENSE file in the project root for more information

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EPiServer.ContentApi.Core.Serialization;
using Geta.Optimizely.GenericLinks.ContentDeliveryApi;

namespace Microsoft.Extensions.DependencyInjection
namespace Microsoft.Extensions.DependencyInjection;

public static class DependencyInjectionExtensions
{
public static class DependencyInjectionExtensions
public static void AddGenericLinkConverters(this IServiceCollection services)
{
public static void AddGenericLinkConverters(this IServiceCollection services)
{
services.AddSingleton<IPropertyConverterProvider>(provider => new GenericLinkConverterProvider(provider));
services.AddSingleton<IPropertyConverterProvider>(provider => new GenericLinkCollectionConverterProvider(provider));
}
services.AddSingleton<IPropertyConverterProvider>(provider => new GenericLinkConverterProvider(provider));
services.AddSingleton<IPropertyConverterProvider>(provider => new GenericLinkCollectionConverterProvider(provider));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,34 @@
using EPiServer.Core;
using Microsoft.Extensions.DependencyInjection;

namespace Geta.Optimizely.GenericLinks.ContentDeliveryApi
namespace Geta.Optimizely.GenericLinks.ContentDeliveryApi;

public class GenericLinkCollectionConverterProvider : IPropertyConverterProvider
{
public class GenericLinkCollectionConverterProvider : IPropertyConverterProvider
private readonly IServiceProvider _serviceProvider;

public GenericLinkCollectionConverterProvider(IServiceProvider serviceProvider)
{
private readonly IServiceProvider _serviceProvider;
_serviceProvider = serviceProvider;
}

public GenericLinkCollectionConverterProvider(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}
public virtual int SortOrder => 100;

public virtual int SortOrder => 100;
public virtual IPropertyConverter Resolve(PropertyData propertyData)
{
var valueType = propertyData.PropertyValueType;
var linkDataType = valueType.GenericTypeArguments.Length > 0 ? valueType.GenericTypeArguments[0] : null;
if (linkDataType is null)
return null;

public virtual IPropertyConverter Resolve(PropertyData propertyData)
if (!typeof(LinkDataCollection).IsAssignableFrom(valueType)
|| !typeof(PropertyLinkDataCollection<>).MakeGenericType(linkDataType).IsAssignableFrom(propertyData.GetOriginalType()))
{
var valueType = propertyData.PropertyValueType;
var linkDataType = valueType.GenericTypeArguments.Length > 0 ? valueType.GenericTypeArguments[0] : null;
if (linkDataType is null)
return null;

if (!typeof(LinkDataCollection).IsAssignableFrom(valueType)
|| !typeof(PropertyLinkDataCollection<>).MakeGenericType(linkDataType).IsAssignableFrom(propertyData.GetOriginalType()))
{
return null;
}
return null;
}

var instanceType = typeof(PropertyGenericLinkCollectionConverter<>).MakeGenericType(linkDataType);
var instanceType = typeof(PropertyGenericLinkCollectionConverter<>).MakeGenericType(linkDataType);

return ActivatorUtilities.CreateInstance(_serviceProvider, instanceType) as IPropertyConverter;
}
return ActivatorUtilities.CreateInstance(_serviceProvider, instanceType) as IPropertyConverter;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,36 @@
using EPiServer.Web.Routing;
using Geta.Optimizely.GenericLinks.Extensions;

namespace Geta.Optimizely.GenericLinks.ContentDeliveryApi
namespace Geta.Optimizely.GenericLinks.ContentDeliveryApi;

public class GenericLinkCollectionPropertyModel<T> : PropertyModel<LinkDataCollection<T>, PropertyLinkDataCollection<T>>, IExpandableProperty<LinkDataCollection<T>> where T : LinkData, new()
{
public class GenericLinkCollectionPropertyModel<T> : PropertyModel<LinkDataCollection<T>, PropertyLinkDataCollection<T>>, IExpandableProperty<LinkDataCollection<T>> where T : LinkData, new()
private readonly IUrlResolver _urlResolver;

public GenericLinkCollectionPropertyModel(PropertyLinkDataCollection<T> propertyLinkData, IUrlResolver urlResolver) : base(propertyLinkData)
{
private readonly IUrlResolver _urlResolver;
_urlResolver = urlResolver;
Value = GetValue(propertyLinkData?.Links);

public GenericLinkCollectionPropertyModel(PropertyLinkDataCollection<T> propertyLinkData, IUrlResolver urlResolver) : base(propertyLinkData)
{
_urlResolver = urlResolver;
Value = GetValue(propertyLinkData?.Links);
ExpandedValue = Value;
}

ExpandedValue = Value;
}
public virtual LinkDataCollection<T> ExpandedValue { get; set; }

public virtual LinkDataCollection<T> ExpandedValue { get; set; }
public virtual void Expand(CultureInfo language)
{
}

public virtual void Expand(CultureInfo language)
{
}
private LinkDataCollection<T> GetValue(LinkDataCollection<T> links)
{
if (links is null)
return null;

private LinkDataCollection<T> GetValue(LinkDataCollection<T> links)
foreach (var link in links)
{
if (links is null)
return null;

foreach (var link in links)
{
link.Href = _urlResolver.GetUrl(link.GetMappedHref());
}

return links;
link.Href = _urlResolver.GetUrl(link.GetMappedHref());
}

return links;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,31 @@
using EPiServer.Core;
using Microsoft.Extensions.DependencyInjection;

namespace Geta.Optimizely.GenericLinks.ContentDeliveryApi
namespace Geta.Optimizely.GenericLinks.ContentDeliveryApi;

public class GenericLinkConverterProvider : IPropertyConverterProvider
{
public class GenericLinkConverterProvider : IPropertyConverterProvider
private readonly IServiceProvider _serviceProvider;

public GenericLinkConverterProvider(IServiceProvider serviceProvider)
{
private readonly IServiceProvider _serviceProvider;
_serviceProvider = serviceProvider;
}

public GenericLinkConverterProvider(IServiceProvider serviceProvider)
{
_serviceProvider = serviceProvider;
}
public virtual int SortOrder => 100;

public virtual int SortOrder => 100;
public virtual IPropertyConverter Resolve(PropertyData propertyData)
{
var valueType = propertyData.PropertyValueType;

public virtual IPropertyConverter Resolve(PropertyData propertyData)
if (!typeof(LinkData).IsAssignableFrom(valueType)
|| !typeof(PropertyLinkData<>).MakeGenericType(valueType).IsAssignableFrom(propertyData.GetOriginalType()))
{
var valueType = propertyData.PropertyValueType;

if (!typeof(LinkData).IsAssignableFrom(valueType)
|| !typeof(PropertyLinkData<>).MakeGenericType(valueType).IsAssignableFrom(propertyData.GetOriginalType()))
{
return null;
}
return null;
}

var instanceType = typeof(PropertyGenericLinkConverter<>).MakeGenericType(valueType);
var instanceType = typeof(PropertyGenericLinkConverter<>).MakeGenericType(valueType);

return ActivatorUtilities.CreateInstance(_serviceProvider, instanceType) as IPropertyConverter;
}
return ActivatorUtilities.CreateInstance(_serviceProvider, instanceType) as IPropertyConverter;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,31 @@
using EPiServer.Web.Routing;
using Geta.Optimizely.GenericLinks.Extensions;

namespace Geta.Optimizely.GenericLinks.ContentDeliveryApi
namespace Geta.Optimizely.GenericLinks.ContentDeliveryApi;

public class GenericLinkPropertyModel<T> : PropertyModel<T, PropertyLinkData<T>>, IExpandableProperty<T> where T : LinkData, new()
{
public class GenericLinkPropertyModel<T> : PropertyModel<T, PropertyLinkData<T>>, IExpandableProperty<T> where T : LinkData, new()
{
private readonly IUrlResolver _urlResolver;
private readonly IUrlResolver _urlResolver;

public GenericLinkPropertyModel(PropertyLinkData<T> propertyLinkData, IUrlResolver urlResolver) : base(propertyLinkData)
{
_urlResolver = urlResolver;
Value = GetValue(propertyLinkData?.Link);
ExpandedValue = Value;
}
public GenericLinkPropertyModel(PropertyLinkData<T> propertyLinkData, IUrlResolver urlResolver) : base(propertyLinkData)
{
_urlResolver = urlResolver;
Value = GetValue(propertyLinkData?.Link);
ExpandedValue = Value;
}

public virtual T ExpandedValue { get; set; }
public virtual T ExpandedValue { get; set; }

public virtual void Expand(CultureInfo language)
{
}
public virtual void Expand(CultureInfo language)
{
}

private T GetValue(T link)
{
if (link is null)
return null;
private T GetValue(T link)
{
if (link is null)
return null;

link.Href = _urlResolver.GetUrl(link.GetMappedHref());
return link;
}
link.Href = _urlResolver.GetUrl(link.GetMappedHref());
return link;
}
}
Loading

0 comments on commit 82c5b18

Please sign in to comment.