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 32 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
4 changes: 3 additions & 1 deletion Lombiq.HelpfulLibraries.AspNetCore/Mvc/JsonModelBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace Lombiq.HelpfulLibraries.AspNetCore.Mvc;

public class JsonModelBinder : IModelBinder
{
private static readonly JsonSerializerOptions DeSerializeOptions = new(JsonSerializerDefaults.Web);

private readonly ILogger<JsonModelBinder> _logger;
private readonly IObjectModelValidator _validator;

Expand All @@ -28,7 +30,7 @@ public Task BindModelAsync(ModelBindingContext bindingContext)
var parsed = value is null ? null : JsonSerializer.Deserialize(
value,
bindingContext.ModelType,
new JsonSerializerOptions(JsonSerializerDefaults.Web));
DeSerializeOptions);

if (parsed is null)
{
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 Expand Up @@ -129,7 +130,7 @@ static void UpdateIfMissing(ref string cookie, ref bool changed, string test, st
context.Response.OnStarting(() =>
{
var setCookie = context.Response.Headers[setCookieHeader];
if (!setCookie.Any()) return Task.CompletedTask;
if (setCookie.Count == 0) return Task.CompletedTask;

var newCookies = new List<string>(capacity: setCookie.Count);
var changed = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
Expand Down Expand Up @@ -46,19 +46,19 @@ public ValueTask UpdateAsync(IDictionary<string, string> securityPolicies, HttpC
{
var any = false;

if (PermittedStyleSources.Any())
if (!PermittedStyleSources.IsEmpty)
{
any = true;
MergeValues(securityPolicies, StyleSrc, PermittedStyleSources);
}

if (PermittedScriptSources.Any())
if (!PermittedScriptSources.IsEmpty)
{
any = true;
MergeValues(securityPolicies, ScriptSrc, PermittedScriptSources);
}

if (PermittedFontSources.Any())
if (!PermittedFontSources.IsEmpty)
{
any = true;
MergeValues(securityPolicies, FontSrc, PermittedFontSources);
Expand Down
5 changes: 2 additions & 3 deletions Lombiq.HelpfulLibraries.Cli/Helpers/CliWrapHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading.Tasks;

namespace Lombiq.HelpfulLibraries.Cli.Helpers;
Expand All @@ -19,7 +18,7 @@ public static class CliWrapHelper
/// <param name="name">The application name you can invoke directly in the command line.</param>
public static async Task<IEnumerable<FileInfo>> WhichAsync(string name)
{
var appName = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "where" : "which";
var appName = OperatingSystem.IsWindows() ? "where" : "which";
var result = await CliWrap.Cli.Wrap(appName)
.WithArguments(name)
.WithValidation(CommandResultValidation.None)
Expand All @@ -46,7 +45,7 @@ public static async Task StreamAsync(
Func<Command, Command> configureCommand = null)
{
var command = CliWrap.Cli.Wrap(program);
if (arguments?.Any() == true) command = command.WithArguments(arguments);
if (arguments?.Count != 0) command = command.WithArguments(arguments);
if (configureCommand != null) command = configureCommand(command);

await foreach (var commandEvent in command.ListenAsync()) handler(commandEvent);
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
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public static IEnumerable<T> EmptyIfNull<T>(this IEnumerable<T> collection) =>
/// cref="Array.Empty{TResult}"/>.
/// </summary>
public static IEnumerable<T> EmptyIfNull<T>(this T[] array) =>
array ?? Array.Empty<T>();
array ?? [];
Psichorex marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Maps the provided collection of pairs using a selector with separate arguments.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static class RandomNumberGeneratorExtensions
/// </remarks>
public static int Next(this RandomNumberGenerator randomNumberGenerator, int minValue, int maxValue)
{
if (minValue > maxValue) throw new ArgumentOutOfRangeException(nameof(minValue));
ArgumentOutOfRangeException.ThrowIfGreaterThan(minValue, maxValue);
if (minValue == maxValue) return minValue;

var diff = (long)maxValue - minValue;
Expand Down
10 changes: 2 additions & 8 deletions Lombiq.HelpfulLibraries.Common/Extensions/StringExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ public static string MakeFileSystemFriendly(this string text, bool noSpaceOrDot
/// Returns an array by splitting the input along commas and stripping empty entries.
/// </summary>
public static string[] SplitByCommas(this string? text) =>
text?.Split(',', StringSplitOptions.RemoveEmptyEntries) ?? Array.Empty<string>();
text?.Split(',', StringSplitOptions.RemoveEmptyEntries) ?? [];

/// <summary>
/// Returns the input split into lines (using <see cref="Environment.NewLine"/>).
/// </summary>
public static string[] SplitByNewLines(this string? text) =>
text?.Split(Environment.NewLine) ?? Array.Empty<string>();
text?.Split(Environment.NewLine) ?? [];

/// <summary>
/// A shortcut for <c>string.Contains(string, StringComparison.InvariantCultureIgnoreCase)</c>. It also safely
Expand All @@ -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,5 +1,4 @@
using LinqToDB;
using System.Diagnostics.CodeAnalysis;

namespace Lombiq.HelpfulLibraries.LinqToDb.Extensions;

Expand All @@ -9,16 +8,13 @@ public static class CustomSqlExtensions
// used by the attribute.
[Sql.Expression(ProviderName.SqlServer, "JSON_VALUE({0}, {1})", ServerSideOnly = true, InlineParameters = true)]
[Sql.Expression(ProviderName.SQLite, "json_extract({0}, {1})", ServerSideOnly = true, InlineParameters = true)]
[SuppressMessage("Usage", "CA1801:Review unused parameters", Justification = "Used in the Sql.Expression attribute.")]
public static string JsonValue(object expression, string path) => null;

[Sql.Expression(ProviderName.SqlServer, "JSON_MODIFY({0}, {1}, {2})", ServerSideOnly = true, InlineParameters = true)]
[Sql.Expression(ProviderName.SQLite, "json_replace({0}, {1}, {2})", ServerSideOnly = true, InlineParameters = true)]
[SuppressMessage("Usage", "CA1801:Review unused parameters", Justification = "Used in the Sql.Expression attribute.")]
public static string JsonModify(string json, string path, string newValue) => null;

[Sql.Expression(ProviderName.SqlServer, "JSON_QUERY({0})", ServerSideOnly = true, InlineParameters = true)]
[Sql.Expression(ProviderName.SQLite, "json({0})", ServerSideOnly = true, InlineParameters = true)]
[SuppressMessage("Usage", "CA1801:Review unused parameters", Justification = "Used in the Sql.Expression attribute.")]
public static string JsonQuery(string value) => null;
}
3 changes: 0 additions & 3 deletions Lombiq.HelpfulLibraries.LinqToDb/LinqToDbQueryExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@ namespace Lombiq.HelpfulLibraries.LinqToDb;

public static class LinqToDbQueryExecutor
{
// We have no control over where these fields are declared.
#pragma warning disable CA1810 // Initialize reference type static fields inline
static LinqToDbQueryExecutor()
#pragma warning restore CA1810 // Initialize reference type static fields inline
{
// Generate aliases for final projection.
Sql.GenerateFinalAliases = true;
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,7 +24,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="linq2db" Version="5.2.2" />
<PackageReference Include="OrchardCore.Data.YesSql" Version="1.7.0" />
<PackageReference Include="linq2db" Version="5.3.2" />
<PackageReference Include="OrchardCore.Data.YesSql" Version="1.8.2" />
</ItemGroup>
</Project>
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 @@ -80,10 +80,10 @@ public static IContent Merge(this IContent content, object properties, JsonMerge
/// <returns>The status of the <see cref="ContentItem"/>'s publication if any.</returns>
public static PublicationStatus GetPublicationStatus(this IContent content)
{
if (content == null) throw new ArgumentNullException(nameof(content));
ArgumentNullException.ThrowIfNull(content);
if (content.ContentItem == null)
{
throw new ArgumentException($"{nameof(content)}.{nameof(content.ContentItem)} shouldn't be null.");
throw new ArgumentNullException($"{nameof(content)}.{nameof(content.ContentItem)} shouldn't be null.");
}

if (content.ContentItem.Published) return PublicationStatus.Published;
Expand Down 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
Expand Up @@ -87,7 +87,7 @@ public static async Task<IEnumerable<ContentItem>> GetOrQueryContentAsync(
// If the published version is already stored, we can return it.
if (contentManagerSession.RecallPublishedItemId(contentItemId, out var contentItem))
{
storedItems ??= new List<ContentItem>();
storedItems ??= [];
Psichorex marked this conversation as resolved.
Show resolved Hide resolved
storedItems.Add(contentItem);
}
}
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
Loading