Skip to content

Commit

Permalink
Port suggestions from net9.0 branch (#16984)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienros authored Nov 11, 2024
1 parent 86516ea commit 5e934c7
Show file tree
Hide file tree
Showing 39 changed files with 55 additions and 47 deletions.
33 changes: 26 additions & 7 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
<PackageVersion Include="MailKit" Version="4.8.0" />
<PackageVersion Include="Markdig" Version="0.37.0" />
<PackageVersion Include="Microsoft.Extensions.Azure" Version="1.7.5" />
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="8.9.1" />
<PackageVersion Include="Microsoft.Identity.Web" Version="3.2.0" />
<!--
Important: the version of the Microsoft.IdentityModel.Protocols.OpenIdConnect package MUST
Expand Down Expand Up @@ -85,11 +84,15 @@
<PackageVersion Include="YesSql.Filters.Abstractions" Version="5.1.1" />
<PackageVersion Include="YesSql.Filters.Query" Version="5.1.1" />
<PackageVersion Include="ZString" Version="2.6.0" />

<!-- dotnet/extensions -->
<PackageVersion Include="Microsoft.Extensions.Http.Resilience" Version="8.10.0" />
</ItemGroup>
<ItemGroup>
<GlobalPackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" />
<GlobalPackageReference Include="Microsoft.CodeAnalysis.CSharp.CodeStyle" Version="4.11.0" />
</ItemGroup>

<!-- These versions are used for tansitive dependency forced upgrades only. E.g. when a package references a vulnerable version. -->
<!-- To list all vulnerable direct references run 'dotnet list package -vulnerable' (use double dash, just XML comments can't contain it) -->
<!-- To list all vulnerable transitive references run 'dotnet list package -vulnerable -include-transitive' (use double dash, just XML comments can't contain it) -->
Expand All @@ -114,14 +117,30 @@
<!-- When removing this, remove the corresponding ignore in dependabot.yml too. -->
<PackageVersion Include="System.Drawing.Common" Version="4.7.2" />
<!--
Microsoft.AspNetCore.DataProtection.StackExchangeRedis (v8.0.8)
└─ Microsoft.AspNetCore.DataProtection (v8.0.8)
└─ System.Security.Cryptography.Xml (v8.0.1)
└─ System.Security.Cryptography.Pkcs (v8.0.0)
└─ System.Formats.Asn1 (v8.0.0)
OrchardCore.Media.Indexing.OpenXML (v2.1.0-preview)
└─ DocumentFormat.OpenXml (v3.1.0)
└─ DocumentFormat.OpenXml.Framework (v3.1.0)
└─ System.IO.Packaging (v8.0.0)
-->
<PackageVersion Include="System.Formats.Asn1" Version="8.0.1" />
<PackageVersion Include="System.IO.Packaging" Version="8.0.1" />

<!--
YesSql (v5.1.1)
└─ YesSql.Provider.SqlServer (v5.1.1)
└─ Microsoft.Data.SqlClient (v5.2.1)
└─ System.Runtime.Caching (v8.0.0)
-->
<PackageVersion Include="System.Runtime.Caching" Version="8.0.1" />

<PackageVersion Include="System.Private.Uri" Version="4.3.2" />

<!-- Several transitive dependencies on 8.0.4 and lower which has known vulnerabilities -->
<PackageVersion Include="System.Text.Json" Version="8.0.5" />

<!-- Several transitive dependencies on 8.0.0 which has known vulnerabilities -->
<PackageVersion Include="Microsoft.Extensions.Caching.Memory" Version="8.0.1" />
</ItemGroup>

<!-- These versions are used for the NuGet packages that are dependent on the current TFM -->
<!-- Versions are preset for the default TFM (there may be no TFM in an evaluation phase) -->
<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"sdk": {
"version": "8.0.101",
"rollForward": "latestFeature"
"rollForward": "latestMajor"
}
}
3 changes: 2 additions & 1 deletion src/OrchardCore.Cms.Web/OrchardCore.Cms.Web.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">
<Project ToolsVersion="15.0" Sdk="Microsoft.NET.Sdk.Web">

<!-- Necessary as we reference the Project and not the Package -->
<Import Project="..\OrchardCore\OrchardCore.Application.Cms.Core.Targets\OrchardCore.Application.Cms.Core.Targets.props" />
Expand All @@ -13,6 +13,7 @@
<!-- With this GUID, user secrets can be added with "dotnet user-secrets set key value" without further changes in
git. See an example use-case at https://docs.orchardcore.net/en/latest/reference/modules/AutoSetup/. -->
<UserSecretsId>2cfccf50-2ae4-4017-bbd7-a0e453cbf713</UserSecretsId>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<!-- For Unit Tests-->
<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using OrchardCore.AdminDashboard.Indexes;
using OrchardCore.ContentManagement.Metadata;
using OrchardCore.ContentManagement.Metadata.Settings;
using OrchardCore.Data.Migration;
using OrchardCore.Recipes;
using OrchardCore.Recipes.Services;
Expand Down
1 change: 0 additions & 1 deletion src/OrchardCore.Modules/OrchardCore.Alias/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
using OrchardCore.Data;
using OrchardCore.Data.Migration;
using OrchardCore.DisplayManagement;
using OrchardCore.DisplayManagement.Descriptors;
using OrchardCore.Indexing;
using OrchardCore.Liquid;
using OrchardCore.Modules;
Expand Down
1 change: 0 additions & 1 deletion src/OrchardCore.Modules/OrchardCore.Autoroute/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
using OrchardCore.Data;
using OrchardCore.Data.Migration;
using OrchardCore.DisplayManagement;
using OrchardCore.DisplayManagement.Descriptors;
using OrchardCore.Indexing;
using OrchardCore.Liquid;
using OrchardCore.Modules;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Text;
using System.Text.Json.Nodes;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Localization;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
using Microsoft.Identity.Web;
using OrchardCore.Deployment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using OrchardCore.Deployment;
using OrchardCore.OpenId.Recipes;
using OrchardCore.OpenId.Services;
using OrchardCore.OpenId.Settings;

namespace OrchardCore.OpenId.Deployment;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ protected override async Task ProcessAsync(OpenIdValidationDeploymentStep step,

result.Steps.Add(new JsonObject
{
["name"] = "OpenIdValidationSettings",
["name"] = nameof(OpenIdValidationSettings),
["OpenIdValidationSettings"] = JObject.FromObject(validationSettings),
});
}
Expand Down
1 change: 0 additions & 1 deletion src/OrchardCore.Modules/OrchardCore.OpenId/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
using OrchardCore.OpenId.Settings;
using OrchardCore.OpenId.Tasks;
using OrchardCore.Recipes;
using OrchardCore.Recipes.Services;
using OrchardCore.Security;
using OrchardCore.Security.Permissions;
using OrchardCore.Settings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ private static bool TryDeserializeParameters(string parameters, out Dictionary<s
try
{
queryParameters = JConvert.DeserializeObject<Dictionary<string, object>>(parameters) ?? [];

return true;
}
catch (JsonException)
{
queryParameters = [];

return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.Diagnostics;
using System.Text;
using System.Text.Json;
using Dapper;
using Fluid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public sealed class RolesMigrations : DataMigration
{
private static readonly string _alternativeAdminRoleName = "SiteOwner";

private SystemRoleOptions _systemRoleOptions;
private readonly SystemRoleOptions _systemRoleOptions;

public RolesMigrations(IOptions<SystemRoleOptions> systemRoleOptions)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Diagnostics;
using System.Globalization;
using System.Text;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Json.Nodes;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Diagnostics;
using System.Globalization;
using System.Text;
using System.Text.Encodings.Web;
using System.Text.Json;
using System.Text.Json.Nodes;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Text.Json.Nodes;
using OrchardCore.Admin;
using OrchardCore.Deployment;
using OrchardCore.Themes.Recipes;
using OrchardCore.Themes.Services;

namespace OrchardCore.Themes.Deployment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public override IDisplayResult Edit(RewriteRule rule, BuildEditorContext context
model.SubstitutionPattern = metadata.SubstitutionPattern;
model.IsCaseInsensitive = metadata.IsCaseInsensitive;
model.QueryStringPolicy = metadata.QueryStringPolicy;
model.RedirectType = Enum.IsDefined(typeof(RedirectType), metadata.RedirectType)
model.RedirectType = Enum.IsDefined<RedirectType>(metadata.RedirectType)
? metadata.RedirectType
: RedirectType.Found;

Expand Down
1 change: 1 addition & 0 deletions src/OrchardCore.Mvc.Web/OrchardCore.Mvc.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace OrchardCore.Deployment;
/// Represents a base class for deployment source.
/// </summary>
/// <typeparam name="TStep">The deployment step type.</typeparam>
public abstract class DeploymentSourceBase<TStep> : IDeploymentSource
public abstract class DeploymentSourceBase<TStep> : IDeploymentSource
where TStep : DeploymentStep
{
/// <inheritdoc/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
using Fluid.Values;
using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using OrchardCore.DisplayManagement.Liquid.Values;
using OrchardCore.DisplayManagement.Shapes;
using OrchardCore.DisplayManagement.Zones;
using OrchardCore.Liquid;

namespace OrchardCore.DisplayManagement.Liquid;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public override void WriteTo(TextWriter writer, TextEncoder encoder, CultureInfo
#pragma warning restore CS0672 // Member overrides obsolete member
=> writer.Write(Culture.Name);

public async override ValueTask WriteToAsync(TextWriter writer, TextEncoder encoder, CultureInfo cultureInfo)
public override async ValueTask WriteToAsync(TextWriter writer, TextEncoder encoder, CultureInfo cultureInfo)
=> await writer.WriteAsync(Culture.Name);

public override ValueTask<FluidValue> GetValueAsync(string name, TemplateContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public override void WriteTo(TextWriter writer, TextEncoder encoder, CultureInfo
#pragma warning restore CS0672 // Member overrides obsolete member
=> writer.Write(ToStringValue());

public async override ValueTask WriteToAsync(TextWriter writer, TextEncoder encoder, CultureInfo cultureInfo)
public override async ValueTask WriteToAsync(TextWriter writer, TextEncoder encoder, CultureInfo cultureInfo)
=> await writer.WriteAsync(ToStringValue());

public override ValueTask<FluidValue> GetValueAsync(string name, TemplateContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public override void WriteTo(TextWriter writer, TextEncoder encoder, CultureInfo
#pragma warning restore CS0672 // Member overrides obsolete member
=> writer.Write(ToStringValue());

public async override ValueTask WriteToAsync(TextWriter writer, TextEncoder encoder, CultureInfo cultureInfo)
public override async ValueTask WriteToAsync(TextWriter writer, TextEncoder encoder, CultureInfo cultureInfo)
=> await writer.WriteAsync(ToStringValue());

public override ValueTask<FluidValue> GetValueAsync(string name, TemplateContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public override void WriteTo(TextWriter writer, TextEncoder encoder, CultureInfo
#pragma warning restore CS0672 // Member overrides obsolete member
=> writer.Write(ToStringValue());

public async override ValueTask WriteToAsync(TextWriter writer, TextEncoder encoder, CultureInfo cultureInfo)
public override async ValueTask WriteToAsync(TextWriter writer, TextEncoder encoder, CultureInfo cultureInfo)
=> await writer.WriteAsync(ToStringValue());

public override ValueTask<FluidValue> GetValueAsync(string name, TemplateContext context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private async Task ApplyImplementationAsync(BuildShapeContext context, string di
// If no specific group is requested, use "" as it represents "any group" when applied on a shape.
// This allows to render shapes when no shape constraints are set and also on specific groups.
var requestedGroup = context.GroupId ?? string.Empty;

// If the shape's group doesn't match the currently rendered one, return.
if (hasGroupConstraints && !_groupIds.Contains(requestedGroup, StringComparer.OrdinalIgnoreCase))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using OrchardCore.OpenId.YesSql.Models;
using OrchardCore.OpenId.YesSql.Resolvers;
using OrchardCore.OpenId.YesSql.Stores;
using YesSql.Indexes;

namespace Microsoft.Extensions.DependencyInjection;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public sealed class ElasticIndexManager
{ ElasticsearchConstants.StopAnalyzer, () => new StopAnalyzer() },
};

private List<string> _tokenFilterNames = new List<string>()
private readonly List<string> _tokenFilterNames = new List<string>()
{
"asciifolding",
"common_grams",
Expand Down Expand Up @@ -457,7 +457,7 @@ public async Task<bool> CreateIndexAsync(ElasticIndexSettings elasticIndexSettin
{
var analyzer = CreateAnalyzer(analyzerProperties);
analysisDescriptor.Analyzers(a => a.UserDefined(analyzerName, analyzer));
}
}

indexSettingsDescriptor = new IndexSettingsDescriptor();
indexSettingsDescriptor.Analysis(an => analysisDescriptor);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class RewriteValidateResult
{
private readonly List<ValidationResult> _errors = [];

public IReadOnlyList<ValidationResult> Errors
public IReadOnlyList<ValidationResult> Errors
=> _errors;

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private static Task PopulateAsync(RewriteRule rule, JsonNode data)
{
metadata.RedirectType = redirectType.Value;
}
else if (!Enum.IsDefined(typeof(RedirectType), metadata.RedirectType))
else if (!Enum.IsDefined<RedirectType>(metadata.RedirectType))
{
metadata.RedirectType = RedirectType.Found;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void Configure(RewriteOptions options)
{
// Exclude URIs prefixed with 'admin' to prevent accidental access restrictions caused by the provided rules.
var prefix = new PathString('/' + _adminOptions.AdminUrlPrefix.TrimStart('/'));

options.Rules.Insert(0, new ExcludeUrlPrefixRule(prefix));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ public DocumentSystemTextJsonOutputFormatter(JsonSerializerOptions jsonSerialize
}

protected override bool CanWriteType(Type type)
=> typeof(IDocument).IsAssignableFrom(type) ||
=> typeof(IDocument).IsAssignableFrom(type) ||
typeof(IEntity).IsAssignableFrom(type);
}
2 changes: 1 addition & 1 deletion src/docs/reference/modules/Workflows/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ public abstract class ActivityDisplayDriver<TActivity, TEditViewModel> : Activit
return Initialize<TEditViewModel>(_editShapeType, viewModel => EditActivityAsync(activity, viewModel)).Location("Content");
}

public async override Task<IDisplayResult> UpdateAsync(TActivity activity, UpdateEditorContext context)
public override async Task<IDisplayResult> UpdateAsync(TActivity activity, UpdateEditorContext context)
{
var viewModel = new TEditViewModel();
if (await context.Updater.TryUpdateModelAsync(viewModel, Prefix))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFrameworks>$(CommonTargetFrameworks)</TargetFrameworks>
<RootNamespace>OrchardCore</RootNamespace>
<!-- Remove the underscores from member name -->
<NoWarn>$(NoWarn);CA1707</NoWarn>
<NoWarn>$(NoWarn);CA1707;EnableGenerateDocumentationFile</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion test/OrchardCore.Benchmarks/OrchardCore.Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<IsPackable>false</IsPackable>
<OutputType>Exe</OutputType>
<!-- Remove the underscores from member name -->
<NoWarn>$(NoWarn);CA1707</NoWarn>
<NoWarn>$(NoWarn);CA1707;EnableGenerateDocumentationFile</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<TargetFrameworks>$(CommonTargetFrameworks)</TargetFrameworks>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
<RazorRuntimeCompilation>false</RazorRuntimeCompilation>
<NoWarn>$(NoWarn);EnableGenerateDocumentationFile</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions test/OrchardCore.Tests/Orchard.Queries/SqlParserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,8 @@ public void ShouldParseSubquery(string sql, string expectedSql)
public void ShouldOrderByRandom(string sql, string expectedSql)
{
// Arrange & Act
var result = SqlParser.TryParse(sql, _schema, _defaultDialect, _defaultTablePrefix, null, out var rawQuery, out var errors);
var result = SqlParser.TryParse(sql, _schema, _defaultDialect, _defaultTablePrefix, null, out var rawQuery, out _);

// Assert
Assert.True(result);
Assert.Equal(expectedSql, FormatSql(rawQuery));
Expand Down
2 changes: 1 addition & 1 deletion test/OrchardCore.Tests/OrchardCore.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<TargetFrameworks>$(CommonTargetFrameworks)</TargetFrameworks>
<!-- Remove the underscores from member name -->
<NoWarn>$(NoWarn);CA1707</NoWarn>
<NoWarn>$(NoWarn);CA1707;EnableGenerateDocumentationFile</NoWarn>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading

0 comments on commit 5e934c7

Please sign in to comment.