From ee339536d5684431857f3b6d3081fa0141556f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Tue, 28 May 2024 11:47:45 +0200 Subject: [PATCH 01/54] Update OC preview version. --- .../Lombiq.HelpfulLibraries.LinqToDb.csproj | 2 +- ...Lombiq.HelpfulLibraries.OrchardCore.csproj | 42 +++++++++---------- .../Lombiq.HelpfulLibraries.Samples.csproj | 12 +++--- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj b/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj index 27434260..2a20507d 100644 --- a/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj +++ b/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj @@ -25,6 +25,6 @@ - + diff --git a/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj b/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj index e956d857..492a3a96 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj +++ b/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj @@ -25,31 +25,31 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - + + diff --git a/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj b/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj index 25f1b628..631bf8ab 100644 --- a/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj +++ b/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj @@ -12,12 +12,12 @@ - - - - - - + + + + + + From 32a76f58ae5a2778a4b4f10036beb02ef15b877f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Tue, 28 May 2024 12:23:52 +0200 Subject: [PATCH 02/54] Fix breaking changes. --- .../Contents/ContentOrchardHelperExtensions.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lombiq.HelpfulLibraries.OrchardCore/Contents/ContentOrchardHelperExtensions.cs b/Lombiq.HelpfulLibraries.OrchardCore/Contents/ContentOrchardHelperExtensions.cs index cfe0057e..1fe6a432 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/Contents/ContentOrchardHelperExtensions.cs +++ b/Lombiq.HelpfulLibraries.OrchardCore/Contents/ContentOrchardHelperExtensions.cs @@ -61,7 +61,7 @@ public static Task GetContentItemOrPreviewAsync( if (httpContext.Request.Method == "POST") { - var previewContentItemId = httpContext.Request.Form["PreviewContentItemId"]; + var previewContentItemId = httpContext.Request.Form["PreviewContentItemId"].ToString(); if (!string.IsNullOrEmpty(previewContentItemId)) { return httpContext.RequestServices.GetService().GetAsync(previewContentItemId); From ca1bf51f8d07326734a6467e7f8a35bf90e96e4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Thu, 30 May 2024 12:26:20 +0200 Subject: [PATCH 03/54] Gut obsolete class. --- .../Mvc/AdminRouteAttributeRouteMapper.cs | 49 +++---------------- 1 file changed, 8 insertions(+), 41 deletions(-) diff --git a/Lombiq.HelpfulLibraries.OrchardCore/Mvc/AdminRouteAttributeRouteMapper.cs b/Lombiq.HelpfulLibraries.OrchardCore/Mvc/AdminRouteAttributeRouteMapper.cs index 6cc61afc..1c276ddc 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/Mvc/AdminRouteAttributeRouteMapper.cs +++ b/Lombiq.HelpfulLibraries.OrchardCore/Mvc/AdminRouteAttributeRouteMapper.cs @@ -1,56 +1,23 @@ -using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Mvc.Controllers; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Options; -using OrchardCore.Admin; using OrchardCore.Mvc.Routing; using System; -using System.Reflection; namespace Lombiq.HelpfulLibraries.OrchardCore.Mvc; -// Mark this class and AdminRouteAttribute as Obsolete when upgrading to the first Orchard Core version that contains -// https://github.com/OrchardCMS/OrchardCore/pull/15251. The message should inform to use [Admin(template)] instead. - -/// -/// A route mapper that maps a route comprised of the and the provided -/// template string to any action that has the . -/// -/// -/// -/// In practice this mapper makes [AdminRoute("My/Path/{id}")] work the same way as if you used -/// [Route("Admin/My/Path/{id}")] except the admin prefix is no longer hard coded. -/// -/// -/// It can be added to the DI service collection using the static method. -/// -/// [Obsolete("Use the [Admin(route)] attribute instead of [AdminRoute(route)].")] public class AdminRouteAttributeRouteMapper : IAreaControllerRouteMapper { - private readonly string _adminUrlPrefix; - - // Must take precedence over AdminAreaControllerRouteMapper whose Order value is -1000. - public int Order => -2000; - - public AdminRouteAttributeRouteMapper(IOptions adminOptions) => - _adminUrlPrefix = adminOptions.Value.AdminUrlPrefix; - - public bool TryMapAreaControllerRoute(IEndpointRouteBuilder routes, ControllerActionDescriptor descriptor) - { - if (descriptor.MethodInfo.GetCustomAttribute() is not { } routeAttribute) return false; + public int Order => 0; - routes.MapAreaControllerRoute( - name: descriptor.DisplayName, - areaName: descriptor.RouteValues["area"], - pattern: $"{_adminUrlPrefix}/{routeAttribute.Template.TrimStart('/')}", - defaults: new { controller = descriptor.ControllerName, action = descriptor.ActionName } - ); + public bool TryMapAreaControllerRoute(IEndpointRouteBuilder routes, ControllerActionDescriptor descriptor) => + ThrowNotSupported(); - return true; - } + public static void AddToServices(IServiceCollection services) => ThrowNotSupported(); - public static void AddToServices(IServiceCollection services) => - services.AddTransient(); + private static bool ThrowNotSupported() => + throw new NotSupportedException( + $"Please disable {nameof(AdminRouteAttributeRouteMapper)} and if you still have controllers or actions " + + $"with the [AdminRoute(route)] attribute, replace them with OrchardCore's built-in [Admin(route)]."); } From e1520e91f07edee3c9f669194c3a9a11293e6113 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Thu, 30 May 2024 13:48:52 +0200 Subject: [PATCH 04/54] Update OC preview version. --- .../Lombiq.HelpfulLibraries.LinqToDb.csproj | 2 +- ...Lombiq.HelpfulLibraries.OrchardCore.csproj | 42 +++++++++---------- .../Lombiq.HelpfulLibraries.Samples.csproj | 12 +++--- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj b/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj index 2a20507d..b8b39d3a 100644 --- a/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj +++ b/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj @@ -25,6 +25,6 @@ - + diff --git a/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj b/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj index 492a3a96..dbe62500 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj +++ b/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj @@ -25,31 +25,31 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - + + diff --git a/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj b/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj index 631bf8ab..f32b1067 100644 --- a/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj +++ b/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj @@ -12,12 +12,12 @@ - - - - - - + + + + + + From 598d32758557895dff326384f1fb719f1408814b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Thu, 30 May 2024 13:52:36 +0200 Subject: [PATCH 05/54] Remove extension method because now OrchardCore.Abstractions has the same thing. --- .../ShellFeaturesManagerExtensions.cs | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 Lombiq.HelpfulLibraries.OrchardCore/Environment/ShellFeaturesManagerExtensions.cs diff --git a/Lombiq.HelpfulLibraries.OrchardCore/Environment/ShellFeaturesManagerExtensions.cs b/Lombiq.HelpfulLibraries.OrchardCore/Environment/ShellFeaturesManagerExtensions.cs deleted file mode 100644 index c4f3548d..00000000 --- a/Lombiq.HelpfulLibraries.OrchardCore/Environment/ShellFeaturesManagerExtensions.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System.Threading.Tasks; - -namespace OrchardCore.Environment.Shell; - -/// -/// Shortcuts for . -/// -public static class ShellFeaturesManagerExtensions -{ - /// - /// Checks whether the given module feature is enabled for the current shell. - /// - /// Technical ID of the module feature. - public static async Task IsFeatureEnabledAsync(this IShellFeaturesManager shellFeaturesManager, string featureId) => - (await shellFeaturesManager.GetEnabledFeaturesAsync()).Any(featureId); -} From 17d2374f997919652f7b142b5594cc7268a092e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Mon, 3 Jun 2024 13:04:00 +0200 Subject: [PATCH 06/54] Add NuGet.Config. --- NuGet.config | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 NuGet.config diff --git a/NuGet.config b/NuGet.config new file mode 100644 index 00000000..c7b3bd52 --- /dev/null +++ b/NuGet.config @@ -0,0 +1,9 @@ + + + + + + + + + From 50217588eec7280e96eb44348e405334bc15442b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Mon, 3 Jun 2024 13:16:50 +0200 Subject: [PATCH 07/54] Revert "Add NuGet.Config." This reverts commit 17d2374f997919652f7b142b5594cc7268a092e6. --- NuGet.config | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 NuGet.config diff --git a/NuGet.config b/NuGet.config deleted file mode 100644 index c7b3bd52..00000000 --- a/NuGet.config +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - From e626beb4380e634f8d33b2c226d9b441771ee157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Wed, 5 Jun 2024 12:11:39 +0200 Subject: [PATCH 08/54] Update OC preview version. --- .../Lombiq.HelpfulLibraries.LinqToDb.csproj | 2 +- ...Lombiq.HelpfulLibraries.OrchardCore.csproj | 42 +++++++++---------- .../Lombiq.HelpfulLibraries.Samples.csproj | 12 +++--- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj b/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj index b8b39d3a..96ee3755 100644 --- a/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj +++ b/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj @@ -25,6 +25,6 @@ - + diff --git a/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj b/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj index dbe62500..92ca7db8 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj +++ b/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj @@ -25,31 +25,31 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - + + diff --git a/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj b/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj index f32b1067..0047f878 100644 --- a/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj +++ b/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj @@ -12,12 +12,12 @@ - - - - - - + + + + + + From 31bcc5e27c5139acecb7388dc07978272ac9bf71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Wed, 5 Jun 2024 15:26:13 +0200 Subject: [PATCH 09/54] Update after API change. --- .../GraphQL/TotalOfContentTypeBuilder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lombiq.HelpfulLibraries.OrchardCore/GraphQL/TotalOfContentTypeBuilder.cs b/Lombiq.HelpfulLibraries.OrchardCore/GraphQL/TotalOfContentTypeBuilder.cs index 58df67a9..035473ff 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/GraphQL/TotalOfContentTypeBuilder.cs +++ b/Lombiq.HelpfulLibraries.OrchardCore/GraphQL/TotalOfContentTypeBuilder.cs @@ -27,7 +27,7 @@ public TotalOfContentTypeBuilder(IStringLocalizer str /// /// The content item type to be extended with the totalOfContentType integer field. /// - public void Build(FieldType contentQuery, ContentTypeDefinition contentTypeDefinition, ContentItemType contentItemType) + public void Build(ISchema schema, FieldType contentQuery, ContentTypeDefinition contentTypeDefinition, ContentItemType contentItemType) { var name = contentTypeDefinition.Name; From db22445ccc5eca142dc5493ec0c4a6b428abb872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Thu, 6 Jun 2024 15:37:09 +0200 Subject: [PATCH 10/54] Copy NuGet.config. --- NuGet.config | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 NuGet.config diff --git a/NuGet.config b/NuGet.config new file mode 100644 index 00000000..c7b3bd52 --- /dev/null +++ b/NuGet.config @@ -0,0 +1,9 @@ + + + + + + + + + From ad32829dc898ce4b0f748e512372f69b2a58fca2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Thu, 6 Jun 2024 18:00:07 +0200 Subject: [PATCH 11/54] Tyy adding package source mapping too. --- NuGet.config | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/NuGet.config b/NuGet.config index c7b3bd52..4b113a8a 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,9 +1,21 @@ + + - - - + + + + + + + + + + + + + From 43319a1c13a64978cbd7a213d7dab6158b5b13bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Thu, 6 Jun 2024 18:26:42 +0200 Subject: [PATCH 12/54] diagnostics --- .github/workflows/publish-cloudsmith.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/publish-cloudsmith.yml b/.github/workflows/publish-cloudsmith.yml index fe5940d3..fbdafa62 100644 --- a/.github/workflows/publish-cloudsmith.yml +++ b/.github/workflows/publish-cloudsmith.yml @@ -12,3 +12,19 @@ jobs: source: https://nuget.cloudsmith.io/lombiq/open-source-orchard-core-extensions/v3/index.json secrets: API_KEY: ${{ secrets.CLOUDSMITH_NUGET_PUBLISH_API_KEY }} + publish-nuget: + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: Lombiq/GitHub-Actions/.github/actions/checkout@dev + with: + token: ${{ secrets.CHECKOUT_TOKEN }} + - name: Set up .NET + uses: Lombiq/GitHub-Actions/.github/actions/setup-dotnet@dev + with: + dotnet-version: 8.0.x + - name: Setup NuGet Version + id: setup + shell: pwsh + run: | + dotnet nuget list source From 324cf8075551ee4cc300105edcdd7c9f25e8c0eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Thu, 6 Jun 2024 18:28:40 +0200 Subject: [PATCH 13/54] diagnostics --- .github/workflows/publish-cloudsmith.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-cloudsmith.yml b/.github/workflows/publish-cloudsmith.yml index fbdafa62..e6a3538b 100644 --- a/.github/workflows/publish-cloudsmith.yml +++ b/.github/workflows/publish-cloudsmith.yml @@ -12,7 +12,7 @@ jobs: source: https://nuget.cloudsmith.io/lombiq/open-source-orchard-core-extensions/v3/index.json secrets: API_KEY: ${{ secrets.CLOUDSMITH_NUGET_PUBLISH_API_KEY }} - publish-nuget: + publish-nuget-info: runs-on: ubuntu-22.04 steps: - name: Checkout From 1782b5b5059c1927fa0c8992f447c15d313f54dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Thu, 6 Jun 2024 18:30:11 +0200 Subject: [PATCH 14/54] also restore --- .github/workflows/publish-cloudsmith.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish-cloudsmith.yml b/.github/workflows/publish-cloudsmith.yml index e6a3538b..99130227 100644 --- a/.github/workflows/publish-cloudsmith.yml +++ b/.github/workflows/publish-cloudsmith.yml @@ -28,3 +28,4 @@ jobs: shell: pwsh run: | dotnet nuget list source + dotnet restore From e58446d78982b5c441d4e32507fea8ef57c8d0e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Thu, 6 Jun 2024 18:49:27 +0200 Subject: [PATCH 15/54] more testing --- .github/workflows/publish-cloudsmith.yml | 2 ++ NuGet.config | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/publish-cloudsmith.yml b/.github/workflows/publish-cloudsmith.yml index 99130227..59766f4a 100644 --- a/.github/workflows/publish-cloudsmith.yml +++ b/.github/workflows/publish-cloudsmith.yml @@ -27,5 +27,7 @@ jobs: id: setup shell: pwsh run: | + dotnet nuget list source + dotnet nuget add source --name orchardcore-preview https://nuget.cloudsmith.io/orchardcore/preview/v3/index.json dotnet nuget list source dotnet restore diff --git a/NuGet.config b/NuGet.config index 4b113a8a..4947077d 100644 --- a/NuGet.config +++ b/NuGet.config @@ -5,7 +5,6 @@ - @@ -14,8 +13,5 @@ - - - From b98572298bdec61abcbff4a1cf56c0708f12aff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Thu, 6 Jun 2024 18:51:53 +0200 Subject: [PATCH 16/54] Revert nuget.config chages. --- NuGet.config | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/NuGet.config b/NuGet.config index 4947077d..3c9b63ca 100644 --- a/NuGet.config +++ b/NuGet.config @@ -5,6 +5,7 @@ + @@ -13,5 +14,8 @@ + + + From 66ce87d7371c091b1cd05440eb5db074241e0d19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Mon, 17 Jun 2024 18:52:24 +0200 Subject: [PATCH 17/54] Copy NuGet.config from NEST. --- NuGet.config | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/NuGet.config b/NuGet.config index 3c9b63ca..28694396 100644 --- a/NuGet.config +++ b/NuGet.config @@ -1,21 +1,31 @@ - - + - - + + + + - - - - + + + - + + + + + + + + + + + From 50d1347812e325d39ef761eb5f1690a7f9931221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Tue, 18 Jun 2024 10:55:11 +0200 Subject: [PATCH 18/54] Update OC version. --- .../Lombiq.HelpfulLibraries.LinqToDb.csproj | 2 +- ...Lombiq.HelpfulLibraries.OrchardCore.csproj | 42 +++++++++---------- .../Lombiq.HelpfulLibraries.Samples.csproj | 12 +++--- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj b/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj index 28f34003..bce43a3f 100644 --- a/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj +++ b/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj @@ -24,6 +24,6 @@ - + diff --git a/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj b/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj index 70b31db5..8e08038e 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj +++ b/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj @@ -24,31 +24,31 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - + + diff --git a/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj b/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj index 0047f878..8b618ea4 100644 --- a/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj +++ b/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj @@ -12,12 +12,12 @@ - - - - - - + + + + + + From d225f86a3c63b0d7d8ba0405d25cbbc0808a335e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Tue, 18 Jun 2024 11:59:32 +0200 Subject: [PATCH 19/54] Update class after interface change. --- .../GraphQL/PartIndexAliasProvider.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Lombiq.HelpfulLibraries.OrchardCore/GraphQL/PartIndexAliasProvider.cs b/Lombiq.HelpfulLibraries.OrchardCore/GraphQL/PartIndexAliasProvider.cs index 12155827..868b0dfd 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/GraphQL/PartIndexAliasProvider.cs +++ b/Lombiq.HelpfulLibraries.OrchardCore/GraphQL/PartIndexAliasProvider.cs @@ -2,6 +2,7 @@ using OrchardCore.ContentManagement.GraphQL.Queries; using System; using System.Collections.Generic; +using System.Threading.Tasks; using YesSql.Indexes; namespace Lombiq.HelpfulLibraries.OrchardCore.GraphQL; @@ -13,7 +14,7 @@ namespace Lombiq.HelpfulLibraries.OrchardCore.GraphQL; public class PartIndexAliasProvider : IIndexAliasProvider where TIndex : class, IIndex { - private static readonly IndexAlias[] _aliases = + private static readonly IEnumerable _aliases = [ new() { @@ -29,5 +30,5 @@ public class PartIndexAliasProvider : IIndexAliasProvider /// /// Gets indexes with a name ending in PartIndex. /// - public IEnumerable GetAliases() => _aliases; + public ValueTask> GetAliasesAsync() => ValueTask.FromResult(_aliases); } From 40eb6c7a33a4bd03b9eb4d9b3603e0c89c95fcbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Wed, 19 Jun 2024 11:19:54 +0200 Subject: [PATCH 20/54] Update OC version. --- .../Lombiq.HelpfulLibraries.LinqToDb.csproj | 2 +- ...Lombiq.HelpfulLibraries.OrchardCore.csproj | 42 +++++++++---------- .../Lombiq.HelpfulLibraries.Samples.csproj | 12 +++--- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj b/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj index bce43a3f..836d6db7 100644 --- a/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj +++ b/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj @@ -24,6 +24,6 @@ - + diff --git a/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj b/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj index 8e08038e..85f05911 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj +++ b/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj @@ -24,31 +24,31 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - + + diff --git a/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj b/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj index 8b618ea4..803303be 100644 --- a/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj +++ b/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj @@ -12,12 +12,12 @@ - - - - - - + + + + + + From f86de9a3b1a1c0b65b4633025c07e9989bedab4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Wed, 19 Jun 2024 22:01:39 +0200 Subject: [PATCH 21/54] LocalizedHtmlStringConverter is not needed. --- .../LocalizedHtmlStringConverter.cs | 48 ------------------- 1 file changed, 48 deletions(-) delete mode 100644 Lombiq.HelpfulLibraries.AspNetCore/Localization/LocalizedHtmlStringConverter.cs diff --git a/Lombiq.HelpfulLibraries.AspNetCore/Localization/LocalizedHtmlStringConverter.cs b/Lombiq.HelpfulLibraries.AspNetCore/Localization/LocalizedHtmlStringConverter.cs deleted file mode 100644 index 382db97f..00000000 --- a/Lombiq.HelpfulLibraries.AspNetCore/Localization/LocalizedHtmlStringConverter.cs +++ /dev/null @@ -1,48 +0,0 @@ -using Microsoft.AspNetCore.Mvc.Localization; -using System; -using System.Collections.Generic; -using System.Text.Json; -using System.Text.Json.Nodes; -using System.Text.Json.Serialization; - -namespace Lombiq.HelpfulLibraries.AspNetCore.Localization; - -public class LocalizedHtmlStringConverter : JsonConverter -{ - public override void Write(Utf8JsonWriter writer, LocalizedHtmlString value, JsonSerializerOptions options) - { - writer.WriteStartObject(); - - writer.WriteString(nameof(LocalizedHtmlString.Name), value.Name); - writer.WriteString(nameof(LocalizedHtmlString.Value), value.Html()); - writer.WriteBoolean(nameof(LocalizedHtmlString.IsResourceNotFound), value.IsResourceNotFound); - - writer.WriteEndObject(); - } - - public override LocalizedHtmlString Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) - { - var token = JsonNode.Parse(ref reader); - - if (token is JsonValue jsonValue) - { - var text = jsonValue.GetValue(); - return new LocalizedHtmlString(text, text); - } - - if (token is JsonObject jsonObject) - { - var dictionary = jsonObject.ToDictionaryIgnoreCase(); - var name = dictionary.GetMaybe(nameof(LocalizedHtmlString.Name))?.Deserialize(); - var value = dictionary.GetMaybe(nameof(LocalizedHtmlString.Value))?.Deserialize() ?? name; - var isResourceNotFound = dictionary.GetMaybe(nameof(LocalizedHtmlString.IsResourceNotFound))?.Deserialize(); - - name ??= value; - if (string.IsNullOrEmpty(name)) throw new InvalidOperationException("Missing name."); - - return new LocalizedHtmlString(name, value, isResourceNotFound == true); - } - - throw new InvalidOperationException($"Can't parse token \"{token}\". It should be an object or a string"); - } -} From c1bfc94ff8d8ae5af442f22aebf1c9e26f3acfc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Thu, 20 Jun 2024 12:28:22 +0200 Subject: [PATCH 22/54] Update OC preview version. --- .../Lombiq.HelpfulLibraries.LinqToDb.csproj | 2 +- ...Lombiq.HelpfulLibraries.OrchardCore.csproj | 42 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj b/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj index 836d6db7..922cc4cb 100644 --- a/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj +++ b/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj @@ -24,6 +24,6 @@ - + diff --git a/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj b/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj index 85f05911..f8a6c33b 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj +++ b/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj @@ -24,31 +24,31 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - + + From 069980607262dc215c4e41ab25d47880158a10d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Fri, 21 Jun 2024 13:11:40 +0200 Subject: [PATCH 23/54] Update OC preview version. --- .../Lombiq.HelpfulLibraries.LinqToDb.csproj | 2 +- ...Lombiq.HelpfulLibraries.OrchardCore.csproj | 42 +++++++++---------- .../Lombiq.HelpfulLibraries.Samples.csproj | 12 +++--- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj b/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj index 836d6db7..a40fcf12 100644 --- a/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj +++ b/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj @@ -24,6 +24,6 @@ - + diff --git a/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj b/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj index 85f05911..fa161174 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj +++ b/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj @@ -24,31 +24,31 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - + + diff --git a/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj b/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj index 803303be..6c0bc910 100644 --- a/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj +++ b/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj @@ -12,12 +12,12 @@ - - - - - - + + + + + + From f26e618e2919385540d00485763901cd87c28c1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Fri, 21 Jun 2024 14:00:44 +0200 Subject: [PATCH 24/54] Remove LocalizedHtmlStringConverter reference. --- .../Converters/LocalizedHtmlStringConverterTests.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Lombiq.HelpfulLibraries.Tests/UnitTests/Converters/LocalizedHtmlStringConverterTests.cs b/Lombiq.HelpfulLibraries.Tests/UnitTests/Converters/LocalizedHtmlStringConverterTests.cs index 6cbd5f45..4e85de57 100644 --- a/Lombiq.HelpfulLibraries.Tests/UnitTests/Converters/LocalizedHtmlStringConverterTests.cs +++ b/Lombiq.HelpfulLibraries.Tests/UnitTests/Converters/LocalizedHtmlStringConverterTests.cs @@ -1,19 +1,18 @@ -using Lombiq.HelpfulLibraries.AspNetCore.Localization; using Microsoft.AspNetCore.Mvc.Localization; using Shouldly; +using System; using System.Text.Json; using Xunit; namespace Lombiq.HelpfulLibraries.Tests.UnitTests.Converters; +[Obsolete("The previously custom LocalizedHtmlStringConverter is not needed in STJ, this test only exists to show " + + "that removing it is safe and non-breaking.")] public class LocalizedHtmlStringConverterTests { private const string Name = "my text"; - private static readonly JsonSerializerOptions _options = new() - { - Converters = { new LocalizedHtmlStringConverter() }, - }; + private static readonly JsonSerializerOptions _options = JOptions.Default; [Theory] [InlineData(Name, Name, null, "{\"Name\":\"my text\",\"Value\":\"my text\",\"IsResourceNotFound\":false}")] From 398a98a5142d4421bff3e70afd5f90e72584072a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Fri, 21 Jun 2024 14:04:03 +0200 Subject: [PATCH 25/54] spelling --- .../UnitTests/Converters/LocalizedHtmlStringConverterTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lombiq.HelpfulLibraries.Tests/UnitTests/Converters/LocalizedHtmlStringConverterTests.cs b/Lombiq.HelpfulLibraries.Tests/UnitTests/Converters/LocalizedHtmlStringConverterTests.cs index 4e85de57..e33efb67 100644 --- a/Lombiq.HelpfulLibraries.Tests/UnitTests/Converters/LocalizedHtmlStringConverterTests.cs +++ b/Lombiq.HelpfulLibraries.Tests/UnitTests/Converters/LocalizedHtmlStringConverterTests.cs @@ -6,8 +6,8 @@ namespace Lombiq.HelpfulLibraries.Tests.UnitTests.Converters; -[Obsolete("The previously custom LocalizedHtmlStringConverter is not needed in STJ, this test only exists to show " + - "that removing it is safe and non-breaking.")] +[Obsolete("The previously custom LocalizedHtmlStringConverter is not needed in System.Text.Json, this test only " + + "exists to show that removing it is safe and non-breaking.")] public class LocalizedHtmlStringConverterTests { private const string Name = "my text"; From 7140386cd1e790d510d16cb33f8b4dad61a2ff22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Mon, 24 Jun 2024 12:37:30 +0200 Subject: [PATCH 26/54] Remove unneeded test. --- .../LocalizedHtmlStringConverterTests.cs | 49 ------------------- 1 file changed, 49 deletions(-) delete mode 100644 Lombiq.HelpfulLibraries.Tests/UnitTests/Converters/LocalizedHtmlStringConverterTests.cs diff --git a/Lombiq.HelpfulLibraries.Tests/UnitTests/Converters/LocalizedHtmlStringConverterTests.cs b/Lombiq.HelpfulLibraries.Tests/UnitTests/Converters/LocalizedHtmlStringConverterTests.cs deleted file mode 100644 index e33efb67..00000000 --- a/Lombiq.HelpfulLibraries.Tests/UnitTests/Converters/LocalizedHtmlStringConverterTests.cs +++ /dev/null @@ -1,49 +0,0 @@ -using Microsoft.AspNetCore.Mvc.Localization; -using Shouldly; -using System; -using System.Text.Json; -using Xunit; - -namespace Lombiq.HelpfulLibraries.Tests.UnitTests.Converters; - -[Obsolete("The previously custom LocalizedHtmlStringConverter is not needed in System.Text.Json, this test only " + - "exists to show that removing it is safe and non-breaking.")] -public class LocalizedHtmlStringConverterTests -{ - private const string Name = "my text"; - - private static readonly JsonSerializerOptions _options = JOptions.Default; - - [Theory] - [InlineData(Name, Name, null, "{\"Name\":\"my text\",\"Value\":\"my text\",\"IsResourceNotFound\":false}")] - [InlineData(Name, Name, false, "{\"Name\":\"my text\",\"Value\":\"my text\",\"IsResourceNotFound\":false}")] - [InlineData(Name, Name, true, "{\"Name\":\"my text\",\"Value\":\"my text\",\"IsResourceNotFound\":true}")] - [InlineData( - Name, - "az én szövegem", // #spell-check-ignore-line - null, - "{\"Name\":\"my text\",\"Value\":\"az \\u00E9n sz\\u00F6vegem\",\"IsResourceNotFound\":false}")] // #spell-check-ignore-line - public void LocalizedHtmlStringShouldBeSerializedCorrectly(string name, string value, bool? notFound, string expected) - { - var localized = notFound == null - ? new LocalizedHtmlString(name, value) - : new LocalizedHtmlString(name, value, notFound.Value); - - JsonSerializer.Serialize(localized, _options).ShouldBe(expected); - } - - [Theory] - [InlineData("\"my text\"", Name, Name, false)] - [InlineData("{ \"name\": \"my text\", \"value\": \"my text\", \"isResourceNotFound\": true }", Name, Name, true)] - [InlineData("{ \"name\": \"my text\", \"value\": \"some other text\" }", Name, "some other text", false)] - [InlineData("{ \"value\": \"my text\" }", Name, Name, false)] - [InlineData("{ \"NAME\": \"my text\" }", Name, Name, false)] - public void LocalizedHtmlStringShouldBeDeserializedCorrectly(string json, string name, string value, bool notFound) - { - var localized = JsonSerializer.Deserialize(json, _options); - - localized.Name.ShouldBe(name); - localized.Value.ShouldBe(value); - localized.IsResourceNotFound.ShouldBe(notFound); - } -} From ae1c83ddbf33f9b61c967874da69746e47bdeb67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Mon, 24 Jun 2024 12:40:45 +0200 Subject: [PATCH 27/54] Switch publish action branch. --- .github/workflows/publish-cloudsmith.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/publish-cloudsmith.yml b/.github/workflows/publish-cloudsmith.yml index 59766f4a..1aec3796 100644 --- a/.github/workflows/publish-cloudsmith.yml +++ b/.github/workflows/publish-cloudsmith.yml @@ -7,7 +7,7 @@ on: jobs: publish-nuget: - uses: Lombiq/GitHub-Actions/.github/workflows/publish-nuget.yml@dev + uses: Lombiq/GitHub-Actions/.github/workflows/publish-nuget.yml@issue/OCC-245 with: source: https://nuget.cloudsmith.io/lombiq/open-source-orchard-core-extensions/v3/index.json secrets: @@ -27,7 +27,5 @@ jobs: id: setup shell: pwsh run: | - dotnet nuget list source - dotnet nuget add source --name orchardcore-preview https://nuget.cloudsmith.io/orchardcore/preview/v3/index.json dotnet nuget list source dotnet restore From 71e7bb298433ad3cf271cceb4b52742d950fd098 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Mon, 24 Jun 2024 13:07:40 +0200 Subject: [PATCH 28/54] Disable add-source-link-package because it breaks dotnet restore. --- .github/workflows/publish-cloudsmith.yml | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/.github/workflows/publish-cloudsmith.yml b/.github/workflows/publish-cloudsmith.yml index 1aec3796..075659ce 100644 --- a/.github/workflows/publish-cloudsmith.yml +++ b/.github/workflows/publish-cloudsmith.yml @@ -10,22 +10,6 @@ jobs: uses: Lombiq/GitHub-Actions/.github/workflows/publish-nuget.yml@issue/OCC-245 with: source: https://nuget.cloudsmith.io/lombiq/open-source-orchard-core-extensions/v3/index.json + add-source-link-package: false secrets: API_KEY: ${{ secrets.CLOUDSMITH_NUGET_PUBLISH_API_KEY }} - publish-nuget-info: - runs-on: ubuntu-22.04 - steps: - - name: Checkout - uses: Lombiq/GitHub-Actions/.github/actions/checkout@dev - with: - token: ${{ secrets.CHECKOUT_TOKEN }} - - name: Set up .NET - uses: Lombiq/GitHub-Actions/.github/actions/setup-dotnet@dev - with: - dotnet-version: 8.0.x - - name: Setup NuGet Version - id: setup - shell: pwsh - run: | - dotnet nuget list source - dotnet restore From fd27f14f1e7c449ce1717171163cd720e8ba9ebb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Mon, 24 Jun 2024 22:15:28 +0200 Subject: [PATCH 29/54] Update OC NuGet versions. --- .../Lombiq.HelpfulLibraries.LinqToDb.csproj | 2 +- ...Lombiq.HelpfulLibraries.OrchardCore.csproj | 42 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj b/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj index a40fcf12..b1e3ea3c 100644 --- a/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj +++ b/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj @@ -24,6 +24,6 @@ - + diff --git a/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj b/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj index fa161174..df69d83d 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj +++ b/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj @@ -24,31 +24,31 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - + + From b26be2a9899dcc5c12b2a2d263e793fbb2143999 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Tue, 2 Jul 2024 19:52:58 +0200 Subject: [PATCH 30/54] Update to latest OC preview version. --- .../Lombiq.HelpfulLibraries.LinqToDb.csproj | 2 +- ...Lombiq.HelpfulLibraries.OrchardCore.csproj | 42 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj b/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj index b1e3ea3c..b76089d7 100644 --- a/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj +++ b/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj @@ -24,6 +24,6 @@ - + diff --git a/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj b/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj index df69d83d..aef5a329 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj +++ b/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj @@ -24,31 +24,31 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - + + From c0ee56a4cd2f809277c14f2a8489ed689dcba672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Thu, 11 Jul 2024 20:16:29 +0200 Subject: [PATCH 31/54] Update OC preview version. --- .../Lombiq.HelpfulLibraries.LinqToDb.csproj | 2 +- ...Lombiq.HelpfulLibraries.OrchardCore.csproj | 42 +++++++++---------- .../Lombiq.HelpfulLibraries.Samples.csproj | 12 +++--- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj b/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj index b76089d7..acabe69c 100644 --- a/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj +++ b/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj @@ -24,6 +24,6 @@ - + diff --git a/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj b/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj index aef5a329..45967d1a 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj +++ b/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj @@ -24,31 +24,31 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - + + diff --git a/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj b/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj index 6c0bc910..c25ed47f 100644 --- a/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj +++ b/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj @@ -12,12 +12,12 @@ - - - - - - + + + + + + From a941653a90d6868793385ec6d6f5e19be0de79bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Leh=C3=B3czky?= Date: Sun, 14 Jul 2024 00:42:44 +0200 Subject: [PATCH 32/54] Updating Refit to 7.1.2 --- .../Lombiq.HelpfulLibraries.Refit.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lombiq.HelpfulLibraries.Refit/Lombiq.HelpfulLibraries.Refit.csproj b/Lombiq.HelpfulLibraries.Refit/Lombiq.HelpfulLibraries.Refit.csproj index ab61c41c..bc029657 100644 --- a/Lombiq.HelpfulLibraries.Refit/Lombiq.HelpfulLibraries.Refit.csproj +++ b/Lombiq.HelpfulLibraries.Refit/Lombiq.HelpfulLibraries.Refit.csproj @@ -24,7 +24,7 @@ - + From 616a1ce2bb97e0722a975844fe7955a39dfbd829 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Sun, 14 Jul 2024 11:47:16 +0200 Subject: [PATCH 33/54] Update CreateModelMaybeAsync to return the viewmodel even if the TryUpdateModelAsync validation fails. Also docs. See https://github.com/OrchardCMS/OrchardCore.Commerce/pull/454#discussion_r1674644842. --- .../Contents/BuildEditorContextExtensions.cs | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/Lombiq.HelpfulLibraries.OrchardCore/Contents/BuildEditorContextExtensions.cs b/Lombiq.HelpfulLibraries.OrchardCore/Contents/BuildEditorContextExtensions.cs index b4abd2c3..d6be0fe7 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/Contents/BuildEditorContextExtensions.cs +++ b/Lombiq.HelpfulLibraries.OrchardCore/Contents/BuildEditorContextExtensions.cs @@ -1,16 +1,38 @@ -using System; +using OrchardCore.DisplayManagement.Entities; +using System; using System.Threading.Tasks; namespace OrchardCore.DisplayManagement.Handlers; public static class BuildEditorContextExtensions { - public static async Task CreateModelMaybeAsync( + /// + /// Creates a new instance of and tries to populate it from the with the . + /// + /// The editor context of the current update request. + /// The name prefix of the fields being edited. + /// + /// If not , it's needed to check the group (e.g. in . The value is checked against the and if they don't match is returned. + /// + /// + /// If not and the awaited result is , then is + /// returned. + /// + /// The expected view-model type. + /// + /// A new instance of , populated with data from . Unless + /// at least one of and are provided and the checks + /// failed, at which case is returned. + /// + public static async Task CreateModelMaybeAsync( this BuildEditorContext context, string prefix, string groupId = null, Func> authorizeAsync = null) - where T : class, new() + where TViewModel : class, new() { if (!string.IsNullOrEmpty(groupId) && context.GroupId != groupId) return null; @@ -19,9 +41,8 @@ public static async Task CreateModelMaybeAsync( return null; } - var viewModel = new T(); - return await context.Updater.TryUpdateModelAsync(viewModel, prefix) - ? viewModel - : null; + var viewModel = new TViewModel(); + await context.Updater.TryUpdateModelAsync(viewModel, prefix); + return viewModel; } } From 69087bdca3ba2ac95ab1b08af226bc93439ff387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Sun, 14 Jul 2024 11:50:24 +0200 Subject: [PATCH 34/54] Use CreateModelMaybeAsync. --- .../Contents/JsonSectionDisplayDriver.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Lombiq.HelpfulLibraries.OrchardCore/Contents/JsonSectionDisplayDriver.cs b/Lombiq.HelpfulLibraries.OrchardCore/Contents/JsonSectionDisplayDriver.cs index 1e81d4c1..3169a880 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/Contents/JsonSectionDisplayDriver.cs +++ b/Lombiq.HelpfulLibraries.OrchardCore/Contents/JsonSectionDisplayDriver.cs @@ -45,11 +45,7 @@ await AuthorizeAsync() public override async Task UpdateAsync(TSection section, UpdateEditorContext context) { - var viewModel = new JsonViewModel(); - - if (context.GroupId == GroupId && - await AuthorizeAsync() && - await context.Updater.TryUpdateModelAsync(viewModel, Prefix) && + if (await context.CreateModelMaybeAsync>(Prefix, GroupId, AuthorizeAsync) is { } viewModel && TryParseJson(viewModel.Json, out var result)) { await UpdateAsync(section, context, result); From e2966008f3118ab3896a0319c9cc4f35e25f7cb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Tue, 16 Jul 2024 18:09:21 +0200 Subject: [PATCH 35/54] Add ConfigureAsync support to InlineStartup. --- .../DependencyInjection/InlineStartup.cs | 10 +++++++++- .../DependencyInjection/ServiceCollectionExtensions.cs | 7 +++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Lombiq.HelpfulLibraries.OrchardCore/DependencyInjection/InlineStartup.cs b/Lombiq.HelpfulLibraries.OrchardCore/DependencyInjection/InlineStartup.cs index 2d45f6ca..a7d3f035 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/DependencyInjection/InlineStartup.cs +++ b/Lombiq.HelpfulLibraries.OrchardCore/DependencyInjection/InlineStartup.cs @@ -3,6 +3,7 @@ using Microsoft.Extensions.DependencyInjection; using OrchardCore.Modules; using System; +using System.Threading.Tasks; namespace Lombiq.HelpfulLibraries.OrchardCore.DependencyInjection; @@ -13,6 +14,7 @@ public class InlineStartup : StartupBase { private readonly Action _configureServices; private readonly Action _configure; + private readonly Func _configureAsync; private readonly int _order; public override int Order => _order; @@ -20,18 +22,21 @@ public class InlineStartup : StartupBase public InlineStartup( Action configureServices, Action configure, + Func configureAsync = null, int order = 0) - : this(configureServices, (app, _, _) => configure(app), order) + : this(configureServices, (app, _, _) => configure(app), configureAsync, order) { } public InlineStartup( Action configureServices, Action configure = null, + Func configureAsync = null, int order = 0) { _configureServices = configureServices; _configure = configure; + _configureAsync = configureAsync; _order = order; } @@ -40,4 +45,7 @@ public override void ConfigureServices(IServiceCollection services) => public override void Configure(IApplicationBuilder app, IEndpointRouteBuilder routes, IServiceProvider serviceProvider) => _configure?.Invoke(app, routes, serviceProvider); + + public override ValueTask ConfigureAsync(IApplicationBuilder app, IEndpointRouteBuilder routes, IServiceProvider serviceProvider) => + _configureAsync?.Invoke(app, routes, serviceProvider) ?? ValueTask.CompletedTask; } diff --git a/Lombiq.HelpfulLibraries.OrchardCore/DependencyInjection/ServiceCollectionExtensions.cs b/Lombiq.HelpfulLibraries.OrchardCore/DependencyInjection/ServiceCollectionExtensions.cs index 8a282561..bbd09a79 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/DependencyInjection/ServiceCollectionExtensions.cs +++ b/Lombiq.HelpfulLibraries.OrchardCore/DependencyInjection/ServiceCollectionExtensions.cs @@ -5,6 +5,7 @@ using Microsoft.Extensions.DependencyInjection.Extensions; using OrchardCore.Modules; using System; +using System.Threading.Tasks; namespace Lombiq.HelpfulLibraries.OrchardCore.DependencyInjection; @@ -28,8 +29,9 @@ public static IServiceCollection AddInlineStartup( this IServiceCollection services, Action configureServices, Action configure, + Func configureAsync = null, int order = 0) => - services.AddSingleton(new InlineStartup(configureServices, configure, order)); + services.AddSingleton(new InlineStartup(configureServices, configure, configureAsync, order)); /// /// Creates a new instance using the provided parameters, and adds it to the service @@ -39,6 +41,7 @@ public static IServiceCollection AddInlineStartup( this IServiceCollection services, Action configureServices, Action configure, + Func configureAsync = null, int order = 0) => - services.AddSingleton(new InlineStartup(configureServices, configure, order)); + services.AddSingleton(new InlineStartup(configureServices, configure, configureAsync, order)); } From ef2b6ba257652dc5d947609a453cbada97b22c01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Tue, 16 Jul 2024 18:17:10 +0200 Subject: [PATCH 36/54] Make them nullable. --- .../DependencyInjection/InlineStartup.cs | 25 ++++++++++--------- .../ServiceCollectionExtensions.cs | 12 +++++---- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/Lombiq.HelpfulLibraries.OrchardCore/DependencyInjection/InlineStartup.cs b/Lombiq.HelpfulLibraries.OrchardCore/DependencyInjection/InlineStartup.cs index a7d3f035..eb6d72d7 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/DependencyInjection/InlineStartup.cs +++ b/Lombiq.HelpfulLibraries.OrchardCore/DependencyInjection/InlineStartup.cs @@ -1,4 +1,6 @@ -using Microsoft.AspNetCore.Builder; +#nullable enable + +using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; using OrchardCore.Modules; @@ -12,32 +14,31 @@ namespace Lombiq.HelpfulLibraries.OrchardCore.DependencyInjection; /// public class InlineStartup : StartupBase { - private readonly Action _configureServices; - private readonly Action _configure; - private readonly Func _configureAsync; - private readonly int _order; + private readonly Action? _configureServices; + private readonly Action? _configure; + private readonly Func? _configureAsync; - public override int Order => _order; + public override int Order { get; } public InlineStartup( - Action configureServices, + Action? configureServices, Action configure, - Func configureAsync = null, + Func? configureAsync = null, int order = 0) : this(configureServices, (app, _, _) => configure(app), configureAsync, order) { } public InlineStartup( - Action configureServices, - Action configure = null, - Func configureAsync = null, + Action? configureServices = null, + Action? configure = null, + Func? configureAsync = null, int order = 0) { _configureServices = configureServices; _configure = configure; _configureAsync = configureAsync; - _order = order; + Order = order; } public override void ConfigureServices(IServiceCollection services) => diff --git a/Lombiq.HelpfulLibraries.OrchardCore/DependencyInjection/ServiceCollectionExtensions.cs b/Lombiq.HelpfulLibraries.OrchardCore/DependencyInjection/ServiceCollectionExtensions.cs index bbd09a79..6f5115f1 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/DependencyInjection/ServiceCollectionExtensions.cs +++ b/Lombiq.HelpfulLibraries.OrchardCore/DependencyInjection/ServiceCollectionExtensions.cs @@ -1,3 +1,5 @@ +#nullable enable + using Lombiq.HelpfulLibraries.Common.DependencyInjection; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Routing; @@ -27,9 +29,9 @@ public static void AddOrchardServices(this IServiceCollection services) /// public static IServiceCollection AddInlineStartup( this IServiceCollection services, - Action configureServices, - Action configure, - Func configureAsync = null, + Action? configureServices = null, + Action? configure = null, + Func? configureAsync = null, int order = 0) => services.AddSingleton(new InlineStartup(configureServices, configure, configureAsync, order)); @@ -39,9 +41,9 @@ public static IServiceCollection AddInlineStartup( /// public static IServiceCollection AddInlineStartup( this IServiceCollection services, - Action configureServices, + Action? configureServices, Action configure, - Func configureAsync = null, + Func? configureAsync = null, int order = 0) => services.AddSingleton(new InlineStartup(configureServices, configure, configureAsync, order)); } From da2f829abd1bf1cf963663302ce558470534cc93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Tue, 16 Jul 2024 18:25:44 +0200 Subject: [PATCH 37/54] Add PrepareShapeTable. --- .../ServiceCollectionExtensions.cs | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Lombiq.HelpfulLibraries.OrchardCore/DependencyInjection/ServiceCollectionExtensions.cs b/Lombiq.HelpfulLibraries.OrchardCore/DependencyInjection/ServiceCollectionExtensions.cs index 6f5115f1..83b09a57 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/DependencyInjection/ServiceCollectionExtensions.cs +++ b/Lombiq.HelpfulLibraries.OrchardCore/DependencyInjection/ServiceCollectionExtensions.cs @@ -5,6 +5,9 @@ using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; +using OrchardCore.Admin; +using OrchardCore.DisplayManagement.Descriptors; +using OrchardCore.DisplayManagement.Theming; using OrchardCore.Modules; using System; using System.Threading.Tasks; @@ -46,4 +49,24 @@ public static IServiceCollection AddInlineStartup( Func? configureAsync = null, int order = 0) => services.AddSingleton(new InlineStartup(configureServices, configure, configureAsync, order)); + + /// + /// Registers an implementation that prepares the shape table for the current site and admin + /// themes. The is the maximum possible value, ensuring that this will be executed + /// right before the site starts serving. + /// + public static IServiceCollection PrepareShapeTable(this IServiceCollection services) => + services.AddInlineStartup( + configureAsync: async (_, _, serviceProvider) => + { + var shapeTableManager = serviceProvider.GetRequiredService(); + + var siteTheme = await serviceProvider.GetRequiredService().GetThemeAsync(); + var adminTheme = await serviceProvider.GetRequiredService().GetAdminThemeAsync(); + + await shapeTableManager.GetShapeTableAsync(themeId: null); + await shapeTableManager.GetShapeTableAsync(siteTheme.Id); + await shapeTableManager.GetShapeTableAsync(adminTheme.Id); + }, + order: int.MaxValue); } From 6462b48394cdffc83f3229c5d2b6e569b8fcc140 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Tue, 16 Jul 2024 18:36:55 +0200 Subject: [PATCH 38/54] Add Cloudsmith badge --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index b68b6166..2897440a 100644 --- a/Readme.md +++ b/Readme.md @@ -1,6 +1,6 @@ # Lombiq Helpful Libraries -[![Lombiq.HelpfulLibraries NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries?label=Lombiq.HelpfulLibraries)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries/) [![Lombiq.HelpfulLibraries.AspNetCore NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.AspNetCore?label=Lombiq.HelpfulLibraries.AspNetCore)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.AspNetCore/) [![Lombiq.HelpfulLibraries.Cli NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.Cli?label=Lombiq.HelpfulLibraries.Cli)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.Cli/) [![Lombiq.HelpfulLibraries.Common NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.Common?label=Lombiq.HelpfulLibraries.Common)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.Common/) [![Lombiq.HelpfulLibraries.LinqToDb NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.LinqToDb?label=Lombiq.HelpfulLibraries.LinqToDb)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.LinqToDb/) [![Lombiq.HelpfulLibraries.OrchardCore NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.OrchardCore?label=Lombiq.HelpfulLibraries.OrchardCore)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.OrchardCore/) [![Lombiq.HelpfulLibraries.OrchardCore.Testing NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.OrchardCore.Testing?label=Lombiq.HelpfulLibraries.OrchardCore.Testing)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.OrchardCore.Testing/) [![Lombiq.HelpfulLibraries.Refit NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.Refit?label=Lombiq.HelpfulLibraries.Refit)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.Refit/) [![Lombiq.HelpfulLibraries.RestEase NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.RestEase?label=Lombiq.HelpfulLibraries.RestEase)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.RestEase/) [![Lombiq.HelpfulLibraries.SourceGenerators NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.SourceGenerators?label=Lombiq.HelpfulLibraries.SourceGenerators)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.SourceGenerators/) [![Lombiq.HelpfulLibraries.Attributes NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.Attributes?label=Lombiq.HelpfulLibraries.Attributes)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.Attributes/) +[![Lombiq.HelpfulLibraries NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries?label=Lombiq.HelpfulLibraries)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries/) [![Lombiq.HelpfulLibraries.AspNetCore NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.AspNetCore?label=Lombiq.HelpfulLibraries.AspNetCore)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.AspNetCore/) [![Lombiq.HelpfulLibraries.Cli NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.Cli?label=Lombiq.HelpfulLibraries.Cli)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.Cli/) [![Lombiq.HelpfulLibraries.Common NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.Common?label=Lombiq.HelpfulLibraries.Common)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.Common/) [![Lombiq.HelpfulLibraries.LinqToDb NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.LinqToDb?label=Lombiq.HelpfulLibraries.LinqToDb)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.LinqToDb/) [![Lombiq.HelpfulLibraries.OrchardCore NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.OrchardCore?label=Lombiq.HelpfulLibraries.OrchardCore)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.OrchardCore/) [![Lombiq.HelpfulLibraries.OrchardCore.Testing NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.OrchardCore.Testing?label=Lombiq.HelpfulLibraries.OrchardCore.Testing)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.OrchardCore.Testing/) [![Lombiq.HelpfulLibraries.Refit NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.Refit?label=Lombiq.HelpfulLibraries.Refit)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.Refit/) [![Lombiq.HelpfulLibraries.RestEase NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.RestEase?label=Lombiq.HelpfulLibraries.RestEase)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.RestEase/) [![Lombiq.HelpfulLibraries.SourceGenerators NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.SourceGenerators?label=Lombiq.HelpfulLibraries.SourceGenerators)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.SourceGenerators/) [![Lombiq.HelpfulLibraries.Attributes NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.Attributes?label=Lombiq.HelpfulLibraries.Attributes)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.Attributes/) [![Cloudsmith](https://api-prd.cloudsmith.io/badges/version/lombiq/open-source-orchard-core-extensions/nuget/Lombiq.HelpfulLibraries/latest/x/?render=true)]([https://cloudsmith.io/~orchardcore/repos/commerce/packages/detail/nuget/OrchardCore.Commerce/latest/](https://cloudsmith.io/~lombiq/repos/open-source-orchard-core-extensions/packages/)) ## About From 97661f11daf485f721ebb30dac58cca992b8c433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Tue, 16 Jul 2024 19:33:48 +0200 Subject: [PATCH 39/54] This is not actually helpful. --- .../ServiceCollectionExtensions.cs | 23 ------------------- 1 file changed, 23 deletions(-) diff --git a/Lombiq.HelpfulLibraries.OrchardCore/DependencyInjection/ServiceCollectionExtensions.cs b/Lombiq.HelpfulLibraries.OrchardCore/DependencyInjection/ServiceCollectionExtensions.cs index 83b09a57..6f5115f1 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/DependencyInjection/ServiceCollectionExtensions.cs +++ b/Lombiq.HelpfulLibraries.OrchardCore/DependencyInjection/ServiceCollectionExtensions.cs @@ -5,9 +5,6 @@ using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection.Extensions; -using OrchardCore.Admin; -using OrchardCore.DisplayManagement.Descriptors; -using OrchardCore.DisplayManagement.Theming; using OrchardCore.Modules; using System; using System.Threading.Tasks; @@ -49,24 +46,4 @@ public static IServiceCollection AddInlineStartup( Func? configureAsync = null, int order = 0) => services.AddSingleton(new InlineStartup(configureServices, configure, configureAsync, order)); - - /// - /// Registers an implementation that prepares the shape table for the current site and admin - /// themes. The is the maximum possible value, ensuring that this will be executed - /// right before the site starts serving. - /// - public static IServiceCollection PrepareShapeTable(this IServiceCollection services) => - services.AddInlineStartup( - configureAsync: async (_, _, serviceProvider) => - { - var shapeTableManager = serviceProvider.GetRequiredService(); - - var siteTheme = await serviceProvider.GetRequiredService().GetThemeAsync(); - var adminTheme = await serviceProvider.GetRequiredService().GetAdminThemeAsync(); - - await shapeTableManager.GetShapeTableAsync(themeId: null); - await shapeTableManager.GetShapeTableAsync(siteTheme.Id); - await shapeTableManager.GetShapeTableAsync(adminTheme.Id); - }, - order: int.MaxValue); } From f304eb964e1ee409582678d8693c96c349e52f33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Tue, 16 Jul 2024 20:39:40 +0200 Subject: [PATCH 40/54] Update Readme.md --- Readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.md b/Readme.md index 2897440a..3759a1bb 100644 --- a/Readme.md +++ b/Readme.md @@ -1,6 +1,6 @@ # Lombiq Helpful Libraries -[![Lombiq.HelpfulLibraries NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries?label=Lombiq.HelpfulLibraries)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries/) [![Lombiq.HelpfulLibraries.AspNetCore NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.AspNetCore?label=Lombiq.HelpfulLibraries.AspNetCore)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.AspNetCore/) [![Lombiq.HelpfulLibraries.Cli NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.Cli?label=Lombiq.HelpfulLibraries.Cli)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.Cli/) [![Lombiq.HelpfulLibraries.Common NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.Common?label=Lombiq.HelpfulLibraries.Common)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.Common/) [![Lombiq.HelpfulLibraries.LinqToDb NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.LinqToDb?label=Lombiq.HelpfulLibraries.LinqToDb)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.LinqToDb/) [![Lombiq.HelpfulLibraries.OrchardCore NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.OrchardCore?label=Lombiq.HelpfulLibraries.OrchardCore)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.OrchardCore/) [![Lombiq.HelpfulLibraries.OrchardCore.Testing NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.OrchardCore.Testing?label=Lombiq.HelpfulLibraries.OrchardCore.Testing)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.OrchardCore.Testing/) [![Lombiq.HelpfulLibraries.Refit NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.Refit?label=Lombiq.HelpfulLibraries.Refit)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.Refit/) [![Lombiq.HelpfulLibraries.RestEase NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.RestEase?label=Lombiq.HelpfulLibraries.RestEase)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.RestEase/) [![Lombiq.HelpfulLibraries.SourceGenerators NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.SourceGenerators?label=Lombiq.HelpfulLibraries.SourceGenerators)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.SourceGenerators/) [![Lombiq.HelpfulLibraries.Attributes NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.Attributes?label=Lombiq.HelpfulLibraries.Attributes)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.Attributes/) [![Cloudsmith](https://api-prd.cloudsmith.io/badges/version/lombiq/open-source-orchard-core-extensions/nuget/Lombiq.HelpfulLibraries/latest/x/?render=true)]([https://cloudsmith.io/~orchardcore/repos/commerce/packages/detail/nuget/OrchardCore.Commerce/latest/](https://cloudsmith.io/~lombiq/repos/open-source-orchard-core-extensions/packages/)) +[![Lombiq.HelpfulLibraries NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries?label=Lombiq.HelpfulLibraries)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries/) [![Lombiq.HelpfulLibraries.AspNetCore NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.AspNetCore?label=Lombiq.HelpfulLibraries.AspNetCore)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.AspNetCore/) [![Lombiq.HelpfulLibraries.Cli NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.Cli?label=Lombiq.HelpfulLibraries.Cli)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.Cli/) [![Lombiq.HelpfulLibraries.Common NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.Common?label=Lombiq.HelpfulLibraries.Common)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.Common/) [![Lombiq.HelpfulLibraries.LinqToDb NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.LinqToDb?label=Lombiq.HelpfulLibraries.LinqToDb)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.LinqToDb/) [![Lombiq.HelpfulLibraries.OrchardCore NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.OrchardCore?label=Lombiq.HelpfulLibraries.OrchardCore)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.OrchardCore/) [![Lombiq.HelpfulLibraries.OrchardCore.Testing NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.OrchardCore.Testing?label=Lombiq.HelpfulLibraries.OrchardCore.Testing)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.OrchardCore.Testing/) [![Lombiq.HelpfulLibraries.Refit NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.Refit?label=Lombiq.HelpfulLibraries.Refit)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.Refit/) [![Lombiq.HelpfulLibraries.RestEase NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.RestEase?label=Lombiq.HelpfulLibraries.RestEase)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.RestEase/) [![Lombiq.HelpfulLibraries.SourceGenerators NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.SourceGenerators?label=Lombiq.HelpfulLibraries.SourceGenerators)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.SourceGenerators/) [![Lombiq.HelpfulLibraries.Attributes NuGet](https://img.shields.io/nuget/v/Lombiq.HelpfulLibraries.Attributes?label=Lombiq.HelpfulLibraries.Attributes)](https://www.nuget.org/packages/Lombiq.HelpfulLibraries.Attributes/) [![Latest version of 'Lombiq.HelpfulLibraries' @ Cloudsmith](https://api-prd.cloudsmith.io/v1/badges/version/lombiq/open-source-orchard-core-extensions/nuget/Lombiq.HelpfulLibraries/latest/xsp=True/?render=true&show_latest=true)](https://cloudsmith.io/~lombiq/repos/open-source-orchard-core-extensions/packages/detail/nuget/Lombiq.HelpfulLibraries/latest/xsp=True/) ## About From 67adcf7354456773d663a4cf745591b521c73fbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Wed, 24 Jul 2024 11:02:08 +0200 Subject: [PATCH 41/54] Update OC preview versions. --- .../Lombiq.HelpfulLibraries.LinqToDb.csproj | 2 +- ...Lombiq.HelpfulLibraries.OrchardCore.csproj | 42 +++++++++---------- .../Lombiq.HelpfulLibraries.Samples.csproj | 12 +++--- 3 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj b/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj index acabe69c..015a3004 100644 --- a/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj +++ b/Lombiq.HelpfulLibraries.LinqToDb/Lombiq.HelpfulLibraries.LinqToDb.csproj @@ -24,6 +24,6 @@ - + diff --git a/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj b/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj index 45967d1a..f83516af 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj +++ b/Lombiq.HelpfulLibraries.OrchardCore/Lombiq.HelpfulLibraries.OrchardCore.csproj @@ -24,31 +24,31 @@ - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - + + diff --git a/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj b/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj index c25ed47f..ea31099d 100644 --- a/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj +++ b/Lombiq.HelpfulLibraries.Samples/Lombiq.HelpfulLibraries.Samples.csproj @@ -12,12 +12,12 @@ - - - - - - + + + + + + From c5899d3084d7f8103a8666bc3d52f77de288d9bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Fri, 26 Jul 2024 21:57:57 +0200 Subject: [PATCH 42/54] Mark ConfigureSmtpSettings obsolete. --- .github/workflows/publish-cloudsmith.yml | 1 - .../Environment/OrchardCoreBuilderExtensions.cs | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/publish-cloudsmith.yml b/.github/workflows/publish-cloudsmith.yml index 075659ce..35c495d6 100644 --- a/.github/workflows/publish-cloudsmith.yml +++ b/.github/workflows/publish-cloudsmith.yml @@ -10,6 +10,5 @@ jobs: uses: Lombiq/GitHub-Actions/.github/workflows/publish-nuget.yml@issue/OCC-245 with: source: https://nuget.cloudsmith.io/lombiq/open-source-orchard-core-extensions/v3/index.json - add-source-link-package: false secrets: API_KEY: ${{ secrets.CLOUDSMITH_NUGET_PUBLISH_API_KEY }} diff --git a/Lombiq.HelpfulLibraries.OrchardCore/Environment/OrchardCoreBuilderExtensions.cs b/Lombiq.HelpfulLibraries.OrchardCore/Environment/OrchardCoreBuilderExtensions.cs index 3e611531..70911a18 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/Environment/OrchardCoreBuilderExtensions.cs +++ b/Lombiq.HelpfulLibraries.OrchardCore/Environment/OrchardCoreBuilderExtensions.cs @@ -2,6 +2,7 @@ using OrchardCore.Email; using OrchardCore.Environment.Shell.Configuration; using OrchardCore.ResourceManagement; +using System; namespace Microsoft.Extensions.DependencyInjection; @@ -29,6 +30,7 @@ public static OrchardCoreBuilder AddDatabaseShellsConfigurationIfAvailable( /// If set to the settings coming from the configuration provider will override the ones set /// up from the admin UI. /// + [Obsolete("The email configuration has changed in OC 2.0, see https://docs.orchardcore.net/en/latest/releases/2.0.0/#email-module.")] public static OrchardCoreBuilder ConfigureSmtpSettings( this OrchardCoreBuilder builder, bool overrideAdminSettings = true) From 9c78566fd695dfdca1a9c90f69573abd37313ec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Sat, 27 Jul 2024 10:04:48 +0200 Subject: [PATCH 43/54] Add tags-ignore. --- .github/workflows/publish-nuget.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index 4b26cfcf..fe7595af 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -4,6 +4,8 @@ on: push: tags: - v* + tags-ignore: + - v*-preview.* jobs: publish-nuget: From 080b03f903fdeeccfeca7b0b5305c6d2829127f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Sat, 27 Jul 2024 10:09:21 +0200 Subject: [PATCH 44/54] Try a different way. --- .github/workflows/publish-nuget.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index fe7595af..a6faee7f 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -4,8 +4,7 @@ on: push: tags: - v* - tags-ignore: - - v*-preview.* + - !v*-preview.* jobs: publish-nuget: From 131b5fb320d16706a3b627f61cdcf8dab302b48c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Sat, 27 Jul 2024 10:19:54 +0200 Subject: [PATCH 45/54] Use if condition instead. --- .github/workflows/publish-nuget.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index a6faee7f..de789bc7 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -4,10 +4,10 @@ on: push: tags: - v* - - !v*-preview.* jobs: publish-nuget: + if: ${{ ! contains(github.ref_name, '-preview.') }} uses: Lombiq/GitHub-Actions/.github/workflows/publish-nuget.yml@dev secrets: API_KEY: ${{ secrets.DEFAULT_NUGET_PUBLISH_API_KEY }} From c8881a8f65621314a800ad0bd925734ab2b83cf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Sat, 27 Jul 2024 11:22:13 +0200 Subject: [PATCH 46/54] Use issue branch in publish-nuget.yml too. --- .github/workflows/publish-nuget.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index de789bc7..87d614f9 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -8,6 +8,6 @@ on: jobs: publish-nuget: if: ${{ ! contains(github.ref_name, '-preview.') }} - uses: Lombiq/GitHub-Actions/.github/workflows/publish-nuget.yml@dev + uses: Lombiq/GitHub-Actions/.github/workflows/publish-nuget.yml@issue/OCC-245 secrets: API_KEY: ${{ secrets.DEFAULT_NUGET_PUBLISH_API_KEY }} From d23b078154c4aed760708f05aa62414bdc224aa5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Sat, 27 Jul 2024 11:45:10 +0200 Subject: [PATCH 47/54] Update UITT version. --- .github/workflows/publish-cloudsmith.yml | 2 +- .github/workflows/publish-nuget.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/publish-cloudsmith.yml b/.github/workflows/publish-cloudsmith.yml index 35c495d6..fe5940d3 100644 --- a/.github/workflows/publish-cloudsmith.yml +++ b/.github/workflows/publish-cloudsmith.yml @@ -7,7 +7,7 @@ on: jobs: publish-nuget: - uses: Lombiq/GitHub-Actions/.github/workflows/publish-nuget.yml@issue/OCC-245 + uses: Lombiq/GitHub-Actions/.github/workflows/publish-nuget.yml@dev with: source: https://nuget.cloudsmith.io/lombiq/open-source-orchard-core-extensions/v3/index.json secrets: diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index 87d614f9..de789bc7 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -8,6 +8,6 @@ on: jobs: publish-nuget: if: ${{ ! contains(github.ref_name, '-preview.') }} - uses: Lombiq/GitHub-Actions/.github/workflows/publish-nuget.yml@issue/OCC-245 + uses: Lombiq/GitHub-Actions/.github/workflows/publish-nuget.yml@dev secrets: API_KEY: ${{ secrets.DEFAULT_NUGET_PUBLISH_API_KEY }} From 8ab13ea5c562b6d2230b7c517b17b7d314a91fc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Sat, 27 Jul 2024 13:51:07 +0200 Subject: [PATCH 48/54] NuGet.config --- NuGet.config | 4 ---- 1 file changed, 4 deletions(-) diff --git a/NuGet.config b/NuGet.config index 28694396..ed23fc59 100644 --- a/NuGet.config +++ b/NuGet.config @@ -4,7 +4,6 @@ - @@ -14,9 +13,6 @@ - - - From 7de578430ac2fa149deead2f2a5496f74212ff38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Sat, 27 Jul 2024 18:56:09 +0200 Subject: [PATCH 49/54] Obsolete CreateAdHocShape. --- .../ResourceManagement/HtmlShape.cs | 52 +++++++++++++++++++ .../ScriptModuleResourceFilter.cs | 6 +-- .../Shapes/ShapeExtensions.cs | 3 ++ 3 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 Lombiq.HelpfulLibraries.OrchardCore/ResourceManagement/HtmlShape.cs diff --git a/Lombiq.HelpfulLibraries.OrchardCore/ResourceManagement/HtmlShape.cs b/Lombiq.HelpfulLibraries.OrchardCore/ResourceManagement/HtmlShape.cs new file mode 100644 index 00000000..2ef425bd --- /dev/null +++ b/Lombiq.HelpfulLibraries.OrchardCore/ResourceManagement/HtmlShape.cs @@ -0,0 +1,52 @@ +using Microsoft.AspNetCore.Html; +using OrchardCore.DisplayManagement; +using OrchardCore.DisplayManagement.Html; +using OrchardCore.DisplayManagement.Shapes; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Data; +using System.IO; +using System.Text.Encodings.Web; +using System.Threading.Tasks; + +namespace Lombiq.HelpfulLibraries.OrchardCore.ResourceManagement; + +// Based on OrchardCore.DisplayManagement.PositionWrapper. +public class HtmlShape : IHtmlContent, IPositioned, IShape +{ + private static readonly IDictionary _dummyAttributes = new Dictionary().ToFrozenDictionary(); + private static readonly IDictionary _dummyProperties = new Dictionary().ToFrozenDictionary(); + + private readonly IHtmlContent _value; + + public string Position { get; set; } + + public ShapeMetadata Metadata { get; set; } = new(); + + public string Id { get; set; } + + public string TagName { get; set; } + + public IList Classes => []; + + public IDictionary Attributes => _dummyAttributes; + + public IDictionary Properties => _dummyProperties; + + public IReadOnlyList Items => []; + + public HtmlShape(IHtmlContent value, string position) + { + _value = value; + Position = position; + } + + public HtmlShape(string value, string position) + : this(new HtmlContentString(value), position) + { + } + + public void WriteTo(TextWriter writer, HtmlEncoder encoder) => _value.WriteTo(writer, encoder); + + public ValueTask AddAsync(object item, string position) => throw new ReadOnlyException(); +} diff --git a/Lombiq.HelpfulLibraries.OrchardCore/ResourceManagement/ScriptModuleResourceFilter.cs b/Lombiq.HelpfulLibraries.OrchardCore/ResourceManagement/ScriptModuleResourceFilter.cs index 1c341e13..66f45c2b 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/ResourceManagement/ScriptModuleResourceFilter.cs +++ b/Lombiq.HelpfulLibraries.OrchardCore/ResourceManagement/ScriptModuleResourceFilter.cs @@ -3,7 +3,6 @@ using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Options; -using OrchardCore.DisplayManagement.Implementation; using OrchardCore.DisplayManagement.Layout; using OrchardCore.ResourceManagement; using System; @@ -25,9 +24,8 @@ public record ScriptModuleResourceFilter(ILayoutAccessor LayoutAccessor) : IAsyn { public async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next) { - var shape = await context.HttpContext.RequestServices.CreateAdHocShapeForCurrentThemeAsync( - nameof(ScriptModuleResourceFilter), - displayContext => Task.FromResult(DisplayScriptModuleResources(displayContext.ServiceProvider))); + var html = DisplayScriptModuleResources(context.HttpContext.RequestServices); + var shape = new HtmlShape(html, "before"); await LayoutAccessor.AddShapeToZoneAsync("Content", shape, "After"); await next(); diff --git a/Lombiq.HelpfulLibraries.OrchardCore/Shapes/ShapeExtensions.cs b/Lombiq.HelpfulLibraries.OrchardCore/Shapes/ShapeExtensions.cs index 147c0c5c..29cd9303 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/Shapes/ShapeExtensions.cs +++ b/Lombiq.HelpfulLibraries.OrchardCore/Shapes/ShapeExtensions.cs @@ -1,3 +1,4 @@ +using Lombiq.HelpfulLibraries.OrchardCore.ResourceManagement; using Microsoft.AspNetCore.Html; using Microsoft.Extensions.DependencyInjection; using OrchardCore.DisplayManagement.Descriptors; @@ -60,6 +61,7 @@ public static T As(this IShape shape) /// name="shapeTable"/>, then a new descriptor is added with binding that uses . /// If is null or empty, a new random unique name is generated. /// + [Obsolete($"This no longer works with the {nameof(DefaultShapeTableManager)}. Use {nameof(HtmlShape)} instead.")] public static IShape CreateAdHocShape(this ShapeTable shapeTable, string type, Func> displayAsync) { if (string.IsNullOrEmpty(type)) type = $"AdHocShape_{Guid.NewGuid():D}"; @@ -102,6 +104,7 @@ public static IShape CreateAdHocShape(this ShapeTable shapeTable, string type, F /// uses . If is null or empty, a new random unique name is /// generated. /// + [Obsolete($"This no longer works with the {nameof(DefaultShapeTableManager)}. Use {nameof(HtmlShape)} instead.")] public static async Task CreateAdHocShapeForCurrentThemeAsync( this IServiceProvider provider, string type, From b341fc12a00f1318e5b42087c858b09e861ee1de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Sat, 27 Jul 2024 21:13:00 +0200 Subject: [PATCH 50/54] Try fixing it for real. --- .../ResourceManagement/HtmlShape.cs | 16 +++++++++------- .../ScriptModuleResourceFilter.cs | 7 ++++--- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Lombiq.HelpfulLibraries.OrchardCore/ResourceManagement/HtmlShape.cs b/Lombiq.HelpfulLibraries.OrchardCore/ResourceManagement/HtmlShape.cs index 2ef425bd..dd9a9fe3 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/ResourceManagement/HtmlShape.cs +++ b/Lombiq.HelpfulLibraries.OrchardCore/ResourceManagement/HtmlShape.cs @@ -1,3 +1,5 @@ +#nullable enable + using Microsoft.AspNetCore.Html; using OrchardCore.DisplayManagement; using OrchardCore.DisplayManagement.Html; @@ -19,13 +21,13 @@ public class HtmlShape : IHtmlContent, IPositioned, IShape private readonly IHtmlContent _value; - public string Position { get; set; } + public string? Position { get; set; } public ShapeMetadata Metadata { get; set; } = new(); - public string Id { get; set; } + public string? Id { get; set; } - public string TagName { get; set; } + public string? TagName { get; set; } public IList Classes => []; @@ -35,14 +37,14 @@ public class HtmlShape : IHtmlContent, IPositioned, IShape public IReadOnlyList Items => []; - public HtmlShape(IHtmlContent value, string position) + public HtmlShape(IHtmlContent? value, string? position = null) { - _value = value; + _value = value ?? new HtmlString(string.Empty); Position = position; } - public HtmlShape(string value, string position) - : this(new HtmlContentString(value), position) + public HtmlShape(string? value, string? position = null) + : this(new HtmlContentString(value ?? string.Empty), position) { } diff --git a/Lombiq.HelpfulLibraries.OrchardCore/ResourceManagement/ScriptModuleResourceFilter.cs b/Lombiq.HelpfulLibraries.OrchardCore/ResourceManagement/ScriptModuleResourceFilter.cs index 66f45c2b..94d250e2 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/ResourceManagement/ScriptModuleResourceFilter.cs +++ b/Lombiq.HelpfulLibraries.OrchardCore/ResourceManagement/ScriptModuleResourceFilter.cs @@ -24,10 +24,11 @@ public record ScriptModuleResourceFilter(ILayoutAccessor LayoutAccessor) : IAsyn { public async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next) { - var html = DisplayScriptModuleResources(context.HttpContext.RequestServices); - var shape = new HtmlShape(html, "before"); + if (DisplayScriptModuleResources(context.HttpContext.RequestServices) is { } html) + { + await LayoutAccessor.AddShapeToZoneAsync(CommonLocationNames.Content, new HtmlShape(html), "After"); + } - await LayoutAccessor.AddShapeToZoneAsync("Content", shape, "After"); await next(); } From 039f062ccc3e412154fff48d905f94cc942cb688 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Sat, 27 Jul 2024 22:43:48 +0200 Subject: [PATCH 51/54] Fix ScriptModuleResourceFilter finally. --- .../ResourceManagement/HtmlShape.cs | 15 ++++++++++----- .../ScriptModuleResourceFilter.cs | 8 ++++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Lombiq.HelpfulLibraries.OrchardCore/ResourceManagement/HtmlShape.cs b/Lombiq.HelpfulLibraries.OrchardCore/ResourceManagement/HtmlShape.cs index dd9a9fe3..3300bf7b 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/ResourceManagement/HtmlShape.cs +++ b/Lombiq.HelpfulLibraries.OrchardCore/ResourceManagement/HtmlShape.cs @@ -4,6 +4,7 @@ using OrchardCore.DisplayManagement; using OrchardCore.DisplayManagement.Html; using OrchardCore.DisplayManagement.Shapes; +using System; using System.Collections.Frozen; using System.Collections.Generic; using System.Data; @@ -13,13 +14,12 @@ namespace Lombiq.HelpfulLibraries.OrchardCore.ResourceManagement; -// Based on OrchardCore.DisplayManagement.PositionWrapper. public class HtmlShape : IHtmlContent, IPositioned, IShape { private static readonly IDictionary _dummyAttributes = new Dictionary().ToFrozenDictionary(); private static readonly IDictionary _dummyProperties = new Dictionary().ToFrozenDictionary(); - private readonly IHtmlContent _value; + private readonly Func _getHtml; public string? Position { get; set; } @@ -37,18 +37,23 @@ public class HtmlShape : IHtmlContent, IPositioned, IShape public IReadOnlyList Items => []; - public HtmlShape(IHtmlContent? value, string? position = null) + public HtmlShape(Func getHtml, string? position = null) { - _value = value ?? new HtmlString(string.Empty); + _getHtml = getHtml; Position = position; } + public HtmlShape(IHtmlContent? value, string? position = null) + : this(() => value, position) + { + } + public HtmlShape(string? value, string? position = null) : this(new HtmlContentString(value ?? string.Empty), position) { } - public void WriteTo(TextWriter writer, HtmlEncoder encoder) => _value.WriteTo(writer, encoder); + public void WriteTo(TextWriter writer, HtmlEncoder encoder) => _getHtml.Invoke()?.WriteTo(writer, encoder); public ValueTask AddAsync(object item, string position) => throw new ReadOnlyException(); } diff --git a/Lombiq.HelpfulLibraries.OrchardCore/ResourceManagement/ScriptModuleResourceFilter.cs b/Lombiq.HelpfulLibraries.OrchardCore/ResourceManagement/ScriptModuleResourceFilter.cs index 94d250e2..18bcb35b 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/ResourceManagement/ScriptModuleResourceFilter.cs +++ b/Lombiq.HelpfulLibraries.OrchardCore/ResourceManagement/ScriptModuleResourceFilter.cs @@ -24,10 +24,10 @@ public record ScriptModuleResourceFilter(ILayoutAccessor LayoutAccessor) : IAsyn { public async Task OnResultExecutionAsync(ResultExecutingContext context, ResultExecutionDelegate next) { - if (DisplayScriptModuleResources(context.HttpContext.RequestServices) is { } html) - { - await LayoutAccessor.AddShapeToZoneAsync(CommonLocationNames.Content, new HtmlShape(html), "After"); - } + await LayoutAccessor.AddShapeToZoneAsync( + CommonLocationNames.Content, + new HtmlShape(() => DisplayScriptModuleResources(context.HttpContext.RequestServices)), + "After"); await next(); } From 5359efa51f40bdc998a7584559c7c2e21a212c12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Sun, 28 Jul 2024 15:26:49 +0200 Subject: [PATCH 52/54] Add HttpRequestInfo. --- .../Mvc/HttpRequestInfo.cs | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Lombiq.HelpfulLibraries.AspNetCore/Mvc/HttpRequestInfo.cs diff --git a/Lombiq.HelpfulLibraries.AspNetCore/Mvc/HttpRequestInfo.cs b/Lombiq.HelpfulLibraries.AspNetCore/Mvc/HttpRequestInfo.cs new file mode 100644 index 00000000..8317fa41 --- /dev/null +++ b/Lombiq.HelpfulLibraries.AspNetCore/Mvc/HttpRequestInfo.cs @@ -0,0 +1,37 @@ +#nullable enable + +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Http.Extensions; +using System.Collections.Generic; +using System.Text.Json; + +namespace Lombiq.HelpfulLibraries.AspNetCore.Mvc; + +/// +/// A simplified intermediate type that can be used to debug . +/// +public record HttpRequestInfo( + string Url, + string? ContentType, + IHeaderDictionary Headers, + IDictionary Form, + IRequestCookieCollection Cookies) +{ + public HttpRequestInfo(HttpRequest request) + : this( + request.GetDisplayUrl(), + request.ContentType, + request.Headers, + request.HasFormContentType ? + request.Form.ToDictionaryIgnoreCase(pair => pair.Key, pair => pair.Value.ToString()) : + new Dictionary(), + request.Cookies) + { + } + + public override string ToString() => $"HTTP Request at \"{Url}\""; + + public string ToJson() => JsonSerializer.Serialize(this); + + public static string? ToJson(HttpRequest? request) => request == null ? null : new HttpRequestInfo(request).ToJson(); +} From 923d3f005a9b1a9dc6e9c735a54ba8c5ccc7ec27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Sun, 28 Jul 2024 22:17:44 +0200 Subject: [PATCH 53/54] Update .github/workflows/publish-nuget.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Zoltán Lehóczky --- .github/workflows/publish-nuget.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/publish-nuget.yml b/.github/workflows/publish-nuget.yml index de789bc7..c2bac93e 100644 --- a/.github/workflows/publish-nuget.yml +++ b/.github/workflows/publish-nuget.yml @@ -7,7 +7,7 @@ on: jobs: publish-nuget: - if: ${{ ! contains(github.ref_name, '-preview.') }} + if: ${{ !contains(github.ref_name, '-preview.') }} uses: Lombiq/GitHub-Actions/.github/workflows/publish-nuget.yml@dev secrets: API_KEY: ${{ secrets.DEFAULT_NUGET_PUBLISH_API_KEY }} From b7e62471833d8c99813cde6be8736dd834366a74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A1ra=20El-Saig?= Date: Sun, 28 Jul 2024 22:57:20 +0200 Subject: [PATCH 54/54] Make ShapeTables created by PerTenantShapeTableManager frozen to match DefaultShapeTableManager where this change was made in PR https://github.com/OrchardCMS/OrchardCore/pull/15651. --- .../Shapes/PerTenantShapeTableManager.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Lombiq.HelpfulLibraries.OrchardCore/Shapes/PerTenantShapeTableManager.cs b/Lombiq.HelpfulLibraries.OrchardCore/Shapes/PerTenantShapeTableManager.cs index 8b858328..f2710480 100644 --- a/Lombiq.HelpfulLibraries.OrchardCore/Shapes/PerTenantShapeTableManager.cs +++ b/Lombiq.HelpfulLibraries.OrchardCore/Shapes/PerTenantShapeTableManager.cs @@ -10,6 +10,7 @@ using OrchardCore.Settings; using System; using System.Collections.Concurrent; +using System.Collections.Frozen; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; @@ -124,8 +125,8 @@ public async Task GetShapeTableAsync(string themeId) .ToList(); shapeTable = new ShapeTable( - descriptors: descriptors.ToDictionary(sd => sd.ShapeType, x => (ShapeDescriptor)x, StringComparer.OrdinalIgnoreCase), - bindings: descriptors.SelectMany(sd => sd.Bindings).ToDictionary(kv => kv.Key, kv => kv.Value, StringComparer.OrdinalIgnoreCase) + descriptors: descriptors.ToFrozenDictionary(sd => sd.ShapeType, x => (ShapeDescriptor)x, StringComparer.OrdinalIgnoreCase), + bindings: descriptors.SelectMany(sd => sd.Bindings).ToFrozenDictionary(kv => kv.Key, kv => kv.Value, StringComparer.OrdinalIgnoreCase) ); if (_logger.IsEnabled(LogLevel.Information))