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

OSOE-751: Upgrade to Orchard Core 1.8 #234

Merged
merged 44 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
25aec62
Adjustments needed for OC 1.8.0.
Psichorex Jan 18, 2024
4db8bd4
Upgrading to .NET 8 and OC 1.8.2.
Psichorex Jan 18, 2024
bad03b4
Merge remote-tracking branch 'origin/dev' into issue/OSOE-751
Psichorex Jan 18, 2024
5d18fdf
Using Append.
Psichorex Jan 18, 2024
57ac665
Updating leftover packages.
Psichorex Jan 18, 2024
1c04ea9
Addressing IDE0290
Psichorex Jan 18, 2024
446e8c6
Addressing warnings.
Psichorex Jan 19, 2024
b5abc48
Addressing warnings.
Psichorex Jan 19, 2024
f2ed7c3
Addressing warnings.
Psichorex Jan 20, 2024
2e30977
Addressing warnings.
Psichorex Jan 20, 2024
8a35be3
Addressing warnings.
Psichorex Jan 20, 2024
109b6b5
Addressing warnings.
Psichorex Jan 20, 2024
44b2009
Addressing warnings.
Psichorex Jan 20, 2024
de1003f
Addressing warnings.
Psichorex Jan 20, 2024
1cdcf85
Removing field.
Psichorex Jan 29, 2024
8e8a009
REmoving fields.
Psichorex Jan 29, 2024
30c92b2
Removing fields.
Psichorex Jan 29, 2024
f2bdd86
Removing fields.
Psichorex Jan 29, 2024
426ca83
Removing field.
Psichorex Jan 29, 2024
7ee991b
Removing field.
Psichorex Jan 29, 2024
aa55837
Keeping T.
Psichorex Jan 29, 2024
3a8bdc0
Keeping T.
Psichorex Jan 29, 2024
968d6de
Keeping T.
Psichorex Jan 29, 2024
afab569
Using better OS determination.
Psichorex Jan 29, 2024
0ddb55d
Removing directive.
Psichorex Jan 29, 2024
3f98d10
Merge remote-tracking branch 'origin/dev' into issue/OSOE-751
Psichorex Jan 30, 2024
9c628b9
Revert "Addressing IDE0290"This reverts commit 1c04ea9d7e524ab95c19da…
Psichorex Jan 30, 2024
48ccf0a
Fix.
Psichorex Jan 30, 2024
dbfd82a
Fixes.
Psichorex Jan 30, 2024
3ae8fb7
Removing space.
Psichorex Jan 31, 2024
416cd1a
Removing ,
Psichorex Jan 31, 2024
f127b12
Some clean-up
Piedone Jan 31, 2024
cff97ea
Warnings.
Psichorex Feb 1, 2024
d31acdb
Update Lombiq.HelpfulLibraries.Tests/UnitTests/Models/TypedRouteTests.cs
Psichorex Feb 1, 2024
382a94c
Minor fixes.
Psichorex Feb 1, 2024
28ed131
Merge branch 'issue/OSOE-751' of https://github.com/Lombiq/Helpful-Li…
Psichorex Feb 1, 2024
1ceef56
Minor fixes.
Psichorex Feb 1, 2024
278d66f
Minor fixing.
Psichorex Feb 1, 2024
116e815
Upgrading from 7.0.0 to 8.0.0 in MS packages.
Psichorex Feb 5, 2024
750436c
Merge remote-tracking branch 'origin/dev' into issue/OSOE-751
Psichorex Feb 5, 2024
ed96315
Fixing TypedRouteTests
Psichorex Feb 5, 2024
8a1aad4
Upgrading MS package.
Psichorex Feb 6, 2024
032a0a5
Using issue branch for publish-nuget.
Psichorex Feb 16, 2024
63483ff
Reverting to dev reference.
Psichorex Feb 21, 2024
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Lombiq.HelpfulLibraries.Common.Utilities;
using Lombiq.HelpfulLibraries.Common.Utilities;
using OrchardCore.Modules;
using System;
using System.Collections.Generic;
using System.Linq;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<DefaultItemExcludes>$(DefaultItemExcludes);.git*</DefaultItemExcludes>
</PropertyGroup>

Expand All @@ -27,6 +27,10 @@
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="OrchardCore.Abstractions" Version="1.8.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Lombiq.HelpfulLibraries.Common\Lombiq.HelpfulLibraries.Common.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Lombiq.HelpfulLibraries.AspNetCore.Security;
using Lombiq.HelpfulLibraries.AspNetCore.Security;
Psichorex marked this conversation as resolved.
Show resolved Hide resolved
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Primitives;
using System;
Expand Down Expand Up @@ -98,7 +99,7 @@ public static IApplicationBuilder UseNosniffContentTypeOptionsHeader(this IAppli

if (!context.Response.Headers.ContainsKey(key))
{
context.Response.Headers.Add(key, "nosniff");
context.Response.Headers.Append(key, "nosniff");
}

await next();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<PropertyGroup>
Expand Down
6 changes: 0 additions & 6 deletions Lombiq.HelpfulLibraries.Common/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,6 @@ public static string[] SplitByNewLines(this string? text) =>
public static bool ContainsLoose(this string? text, string? toFind) =>
text != null && toFind != null && text.Contains(toFind, StringComparison.InvariantCultureIgnoreCase);

/// <summary>
/// A shortcut for <c>string.Equals(string, StringComparison.OrdinalIgnoreCase)</c>.
/// </summary>
public static bool EqualsOrdinalIgnoreCase(this string text, string? value) =>
text.Equals(value, StringComparison.OrdinalIgnoreCase);

Piedone marked this conversation as resolved.
Show resolved Hide resolved
/// <summary>
/// A shortcut for <c>string.Contains(string, StringComparison.OrdinalIgnoreCase)</c>.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<DefaultItemExcludes>$(DefaultItemExcludes);.git*</DefaultItemExcludes>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<DefaultItemExcludes>$(DefaultItemExcludes);.git*</DefaultItemExcludes>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<DefaultItemExcludes>$(DefaultItemExcludes);.git*</DefaultItemExcludes>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Microsoft.Extensions.Localization;
using OrchardCore.ContentManagement.Metadata;
using OrchardCore.Environment.Commands;
using System.Threading.Tasks;

namespace Lombiq.HelpfulLibraries.OrchardCore.Contents;

Expand Down Expand Up @@ -28,6 +29,6 @@ public ContentDefinitionCommands(
" /Part:<contentPartName>" +
"\r\n\t" + "Attaches a content part to a content type.")]
[OrchardSwitches(nameof(Type) + ", " + nameof(Part))]
public void AttachContentPart() =>
_contentDefinitionManager.AlterTypeDefinition(Type, type => type.WithPart(Part));
public Task AttachContentPartAsync() =>
_contentDefinitionManager.AlterTypeDefinitionAsync(Type, type => type.WithPart(Part));
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using OrchardCore.ContentManagement.Metadata.Builders;
using System;
using System.Linq;
using System.Threading.Tasks;

namespace OrchardCore.ContentManagement.Metadata;

Expand All @@ -13,13 +14,13 @@ public static class ContentDefinitionManagerExtensions
/// <param name="contentType">Technical name of the content type.</param>
/// <param name="contentPartName">Technical name of the content part.</param>
/// <returns>Content part settings object.</returns>
public static T GetContentPartSettings<T>(
public static async Task<T> GetContentPartSettingsAsync<T>(
this IContentDefinitionManager contentDefinitionManager,
string contentType,
string contentPartName)
where T : class, new()
{
var contentTypeDefinition = contentDefinitionManager.GetTypeDefinition(contentType);
var contentTypeDefinition = await contentDefinitionManager.GetTypeDefinitionAsync(contentType);
var contentTypePartDefinition = contentTypeDefinition.Parts
.FirstOrDefault(part => part.PartDefinition.Name == contentPartName);

Expand All @@ -30,20 +31,20 @@ public static T GetContentPartSettings<T>(
/// Alters the definition of a content part whose technical name is its model's type name. It uses the typed wrapper
/// <see cref="ContentPartDefinitionBuilder{TPart}"/> for configuration.
/// </summary>
public static string AlterPartDefinition<TPart>(
public static async Task<string> AlterPartDefinitionAsync<TPart>(
this IContentDefinitionManager manager,
Action<ContentPartDefinitionBuilder<TPart>> configure)
where TPart : ContentPart
{
var name = typeof(TPart).Name;
manager.AlterPartDefinition(name, part => configure(part.AsPart<TPart>()));
await manager.AlterPartDefinitionAsync(name, part => configure(part.AsPart<TPart>()));
return name;
}

/// <summary>
/// Prepares a <paramref name="contentType"/> to be used as a Taxonomy by resetting all content type settings to
/// <see langword="false"/> and adding <c>TitlePart</c>.
/// </summary>
public static void AlterTypeDefinitionForTaxonomy(this IContentDefinitionManager manager, string contentType) =>
manager.AlterTypeDefinition(contentType, type => type.NoAbilities().WithTitlePart());
public static Task AlterTypeDefinitionForTaxonomyAsync(this IContentDefinitionManager manager, string contentType) =>
manager.AlterTypeDefinitionAsync(contentType, type => type.NoAbilities().WithTitlePart());
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public static async Task SanitizeContentItemVersionsAsync(this IContent content,
{
toRemove.Published = false;
toRemove.Latest = false;
session.Save(toRemove);
await session.SaveAsync(toRemove);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using OrchardCore.Data.Migration;
using System.Threading.Tasks;
using YesSql.Indexes;
using YesSql.Sql;
using YesSql.Sql.Schema;
Expand All @@ -15,11 +16,11 @@ public abstract class IndexDataMigration<TIndex> : DataMigration
{
protected virtual int CreateVersion => 1;

public int Create()
public async Task<int> CreateAsync()
{
SchemaBuilder.CreateMapIndexTable<TIndex>(CreateIndex);
await SchemaBuilder.CreateMapIndexTableAsync<TIndex>(CreateIndex);

SchemaBuilder.CreateDocumentIdIndex<TIndex>();
await SchemaBuilder.CreateDocumentIdIndexAsync<TIndex>();

return CreateVersion;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using YesSql.Sql;

namespace Lombiq.HelpfulLibraries.OrchardCore.Data;
Expand All @@ -15,8 +16,8 @@ public static class SchemaBuilderExtensions
/// </summary>
/// <typeparam name="T">Index table type.</typeparam>
/// <param name="schemaBuilder">SchemaBuilder Interface.</param>
public static void CreateDocumentIdIndex<T>(this ISchemaBuilder schemaBuilder) =>
schemaBuilder.AlterTable(typeof(T).Name, table => table
public static Task CreateDocumentIdIndexAsync<T>(this ISchemaBuilder schemaBuilder) =>
schemaBuilder.AlterTableAsync(typeof(T).Name, table => table
.CreateIndex(
$"IDX_{typeof(T).Name}_{DocumentId}",
DocumentId));
Expand All @@ -34,7 +35,7 @@ public static void CreateDocumentIdIndex<T>(this ISchemaBuilder schemaBuilder) =
/// <exception cref="ArgumentException">
/// It is thrown when the <paramref name="columnNames"/> is null or empty.
/// </exception>
public static ISchemaBuilder AddDatabaseIndex<TTable>(this ISchemaBuilder schemaBuilder, params string[] columnNames)
public static Task AddDatabaseIndexAsync<TTable>(this ISchemaBuilder schemaBuilder, params string[] columnNames)
{
if (columnNames?.Any() != true)
{
Expand All @@ -44,11 +45,11 @@ public static ISchemaBuilder AddDatabaseIndex<TTable>(this ISchemaBuilder schema
if (columnNames.Exists(string.IsNullOrWhiteSpace))
{
throw new ArgumentException(
"The column names shouldn't be null, empty or all whitespace.",
"The column names shouldn't be null, empty, or all whitespace.",
nameof(columnNames));
}

return schemaBuilder.AlterTable(typeof(TTable).Name, table => table
return schemaBuilder.AlterTableAsync(typeof(TTable).Name, table => table
.CreateIndex(
$"IDX_{typeof(TTable).Name}_{string.Join('_', columnNames)}",
columnNames));
Expand All @@ -57,10 +58,10 @@ public static ISchemaBuilder AddDatabaseIndex<TTable>(this ISchemaBuilder schema
/// <summary>
/// Creates a Map Index table with the provided index type of <typeparamref name="T"/>.
/// </summary>
public static ISchemaBuilder CreateMapIndexTable<T>(
public static Task CreateMapIndexTableAsync<T>(
this ISchemaBuilder builder,
string collection = null) =>
builder.CreateMapIndexTable(
builder.CreateMapIndexTableAsync(
typeof(T),
table =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,18 @@ public class NoneShapeTableProvider : IShapeTableProvider
public NoneShapeTableProvider(IContentDefinitionManager contentDefinitionManager) =>
_contentDefinitionManager = contentDefinitionManager;

public void Discover(ShapeTableBuilder builder)
{
// The interface requires this method to be implemented so this is temporarily here.
// Remove this method once it gets deleted in IShapeTableProvider.
}

/// <summary>
/// Adds a "None" option to every field's display and editor and renders an empty shape.
/// </summary>
public void Discover(ShapeTableBuilder builder)
public async Task DiscoverAsync(ShapeTableBuilder builder)
{
var allFieldNames = _contentDefinitionManager
.ListPartDefinitions()
var allFieldNames = (await _contentDefinitionManager.ListPartDefinitionsAsync())
.SelectMany(part => part.Fields)
.Select(field => field.FieldDefinition.Name)
.Distinct();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<DefaultItemExcludes>$(DefaultItemExcludes);.git*</DefaultItemExcludes>
</PropertyGroup>

Expand All @@ -24,26 +24,26 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OrchardCore.Alias" Version="1.7.0" />
<PackageReference Include="OrchardCore.Autoroute" Version="1.7.0" />
<PackageReference Include="OrchardCore.Html" Version="1.7.0" />
<PackageReference Include="OrchardCore.Markdown" Version="1.7.0" />
<PackageReference Include="OrchardCore.Media.Core" Version="1.7.0" />
<PackageReference Include="OrchardCore.Taxonomies" Version="1.7.0" />
<PackageReference Include="OrchardCore.ContentManagement" Version="1.7.0" />
<PackageReference Include="OrchardCore.ContentManagement.Abstractions" Version="1.7.0" />
<PackageReference Include="OrchardCore.FileStorage.Abstractions" Version="1.7.0" />
<PackageReference Include="OrchardCore.Queries" Version="1.7.0" />
<PackageReference Include="OrchardCore.Users.Core" Version="1.7.0" />
<PackageReference Include="OrchardCore.Title" Version="1.7.0" />
<PackageReference Include="OrchardCore.Themes" Version="1.7.0" />
<PackageReference Include="OrchardCore.Email.Abstractions" Version="1.7.0" />
<PackageReference Include="OrchardCore.Infrastructure" Version="1.7.0" />
<PackageReference Include="NodaTime" Version="3.1.9" />
<PackageReference Include="OrchardCore.Alias" Version="1.8.2" />
<PackageReference Include="OrchardCore.Autoroute" Version="1.8.2" />
<PackageReference Include="OrchardCore.Html" Version="1.8.2" />
<PackageReference Include="OrchardCore.Markdown" Version="1.8.2" />
<PackageReference Include="OrchardCore.Media.Core" Version="1.8.2" />
<PackageReference Include="OrchardCore.Taxonomies" Version="1.8.2" />
<PackageReference Include="OrchardCore.ContentManagement" Version="1.8.2" />
<PackageReference Include="OrchardCore.ContentManagement.Abstractions" Version="1.8.2" />
<PackageReference Include="OrchardCore.FileStorage.Abstractions" Version="1.8.2" />
<PackageReference Include="OrchardCore.Queries" Version="1.8.2" />
<PackageReference Include="OrchardCore.Users.Core" Version="1.8.2" />
<PackageReference Include="OrchardCore.Title" Version="1.8.2" />
<PackageReference Include="OrchardCore.Themes" Version="1.8.2" />
<PackageReference Include="OrchardCore.Email.Abstractions" Version="1.8.2" />
<PackageReference Include="OrchardCore.Infrastructure" Version="1.8.2" />
<PackageReference Include="NodaTime" Version="3.1.10" />
<!-- Necessary so tag helpers will work in the projects depending on this. -->
<PackageReference Include="OrchardCore.DisplayManagement" Version="1.7.0" />
<PackageReference Include="OrchardCore.ResourceManagement" Version="1.7.0" />
<PackageReference Include="OrchardCore.Workflows.Abstractions" Version="1.7.0" />
<PackageReference Include="OrchardCore.DisplayManagement" Version="1.8.2" />
<PackageReference Include="OrchardCore.ResourceManagement" Version="1.8.2" />
<PackageReference Include="OrchardCore.Workflows.Abstractions" Version="1.8.2" />
<PackageReference Include="OrchardCore.Setup.Abstractions" Version="1.7.0" />
</ItemGroup>

Expand Down
1 change: 1 addition & 0 deletions Lombiq.HelpfulLibraries.OrchardCore/Mvc/TypedRoute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Newtonsoft.Json;
using OrchardCore.Admin;
using OrchardCore.Environment.Extensions;
using OrchardCore.Modules;
using OrchardCore.Modules.Manifest;
using OrchardCore.Mvc.Core.Utilities;
using System;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Lombiq.HelpfulLibraries.Common.Utilities;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Localization;
using OrchardCore.Modules;
using OrchardCore.Navigation;
using System;
using System.Threading.Tasks;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public async Task<ShapeTable> GetShapeTableAsync(string themeId)
var strategyFeature = _typeFeatureProvider.GetFeatureForDependency(bindingStrategy.GetType());

var builder = new ShapeTableBuilder(strategyFeature, excludedFeatures);
bindingStrategy.Discover(builder);
await bindingStrategy.DiscoverAsync(builder);
var builtAlterations = builder.BuildAlterations();

BuildDescriptors(bindingStrategy, builtAlterations, shapeDescriptors);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Mvc.Localization;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Razor.TagHelpers;
using System;
using OrchardCore.Modules;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<DefaultItemExcludes>$(DefaultItemExcludes);.git*</DefaultItemExcludes>
</PropertyGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<IsPackable>false</IsPackable>
<DefaultItemExcludes>$(DefaultItemExcludes);.git*;node_modules\**;Tests\**</DefaultItemExcludes>
Expand All @@ -12,12 +12,12 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OrchardCore.ContentFields" Version="1.7.0" />
<PackageReference Include="OrchardCore.Module.Targets" Version="1.7.0" />
<PackageReference Include="OrchardCore.ContentManagement" Version="1.7.0" />
<PackageReference Include="OrchardCore.ContentTypes.Abstractions" Version="1.7.0" />
<PackageReference Include="OrchardCore.DisplayManagement" Version="1.7.0" />
<PackageReference Include="OrchardCore.Autoroute" Version="1.7.0" />
<PackageReference Include="OrchardCore.ContentFields" Version="1.8.2" />
<PackageReference Include="OrchardCore.Module.Targets" Version="1.8.2" />
<PackageReference Include="OrchardCore.ContentManagement" Version="1.8.2" />
<PackageReference Include="OrchardCore.ContentTypes.Abstractions" Version="1.8.2" />
<PackageReference Include="OrchardCore.DisplayManagement" Version="1.8.2" />
<PackageReference Include="OrchardCore.Autoroute" Version="1.8.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading