From f02437da83ab0973149030708722caa52f66ffb9 Mon Sep 17 00:00:00 2001 From: Emrah Tokalak Date: Sat, 9 Nov 2024 23:37:53 +0300 Subject: [PATCH 01/63] =?UTF-8?q?Fix=20JSON=20parsing=20errors=20caused=20?= =?UTF-8?q?by=20spaces=20and=20special=20characters=20in=20Lu=E2=80=A6=20(?= =?UTF-8?q?#16981)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: emrah.tokalak Co-authored-by: Hisham Bin Ateya --- .../Controllers/AdminController.cs | 2 +- .../Services/LuceneQuerySource.cs | 3 ++- .../Apis/Lucene/LuceneQueryTests.cs | 22 +++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Controllers/AdminController.cs b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Controllers/AdminController.cs index e755edd1f48..c8245412ab2 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Controllers/AdminController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Controllers/AdminController.cs @@ -413,7 +413,7 @@ await _luceneIndexManager.SearchAsync(model.IndexName, async searcher => try { - var parameterizedQuery = JsonNode.Parse(tokenizedContent).AsObject(); + var parameterizedQuery = JsonNode.Parse(tokenizedContent, JOptions.Node, JOptions.Document).AsObject(); var luceneTopDocs = await _queryService.SearchAsync(context, parameterizedQuery); if (luceneTopDocs != null) diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Services/LuceneQuerySource.cs b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Services/LuceneQuerySource.cs index 6171668661e..bf50b634921 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Services/LuceneQuerySource.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Services/LuceneQuerySource.cs @@ -1,4 +1,5 @@ using System.Text.Encodings.Web; +using System.Text.Json; using System.Text.Json.Nodes; using Fluid; using Fluid.Values; @@ -60,7 +61,7 @@ await _luceneIndexManager.SearchAsync(metadata.Index, async searcher => { var tokenizedContent = await _liquidTemplateManager.RenderStringAsync(metadata.Template, _javaScriptEncoder, parameters.Select(x => new KeyValuePair(x.Key, FluidValue.Create(x.Value, _templateOptions)))); - var parameterizedQuery = JsonNode.Parse(tokenizedContent).AsObject(); + var parameterizedQuery = JsonNode.Parse(tokenizedContent, JOptions.Node, JOptions.Document).AsObject(); var analyzer = _luceneAnalyzerManager.CreateAnalyzer(await _luceneIndexSettingsService.GetIndexAnalyzerAsync(metadata.Index)); var context = new LuceneQueryContext(searcher, LuceneSettings.DefaultVersion, analyzer); diff --git a/test/OrchardCore.Tests/Apis/Lucene/LuceneQueryTests.cs b/test/OrchardCore.Tests/Apis/Lucene/LuceneQueryTests.cs index 2e9f335a2c8..038df8138c2 100644 --- a/test/OrchardCore.Tests/Apis/Lucene/LuceneQueryTests.cs +++ b/test/OrchardCore.Tests/Apis/Lucene/LuceneQueryTests.cs @@ -152,4 +152,26 @@ public async Task TwoWildcardQueriesWithBoostHasResults() Assert.Contains("Orchard", contentItems.ElementAt(3).DisplayText, StringComparison.OrdinalIgnoreCase); }; } + + [Fact] + public async Task LuceneQueryTemplateWithSpecialCharactersShouldNotThrowError() + { + using var context = new LuceneContext(); + await context.InitializeAsync(); + + // Act + var index = "ArticleIndex"; + var queryTemplate = "\r\r\n{% assign testVariable = \"48yvsghn194eft8axztaves25h\" %}\n\n{\n \"query\": {\n \"bool\": {\n \"must\": [\n { \"term\" : { \"Content.ContentItem.ContentType\" : \"Article\" } },\n { \"term\": { \"Content.ContentItem.Published\" : \"true\" } },\n ]\n }\n }\n}"; + + var content = await context.Client.GetAsync($"api/lucene/content?indexName={index}&query={queryTemplate}"); + var queryResults = await content.Content.ReadAsAsync(); + + // Assert + Assert.NotNull(queryResults); + Assert.NotEmpty(queryResults.Items); + + var contentItems = queryResults.Items.Select(x => JObject.FromObject(x).Deserialize()); + + Assert.Contains("Orchard", contentItems.First().DisplayText, StringComparison.OrdinalIgnoreCase); + } } From ebde3eca50c51da0eb5d192dc2a5b4cbe82bde51 Mon Sep 17 00:00:00 2001 From: Hisham Bin Ateya Date: Sun, 10 Nov 2024 00:04:01 +0300 Subject: [PATCH 02/63] Introduce HttpRequest & HttpContext Fluid values (#16979) Co-authored-by: Sebastien Ros --- .../LiquidHttpContextAccessor.cs | 1 + .../LiquidRequestAccessor.cs | 1 + .../TemplateOptionsConfigurations.cs | 93 +------------------ .../Values/CookieCollectionWrapper.cs | 13 +++ .../Values/HeaderDictionaryWrapper.cs | 13 +++ .../Values/HttpContextItemsWrapper.cs | 11 +++ .../Values/HttpContextValue.cs | 66 +++++++++++++ .../Values/HttpRequestValue.cs | 89 ++++++++++++++++++ .../Values/RouteValueDictionaryWrapper.cs | 11 +++ 9 files changed, 207 insertions(+), 91 deletions(-) create mode 100644 src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/CookieCollectionWrapper.cs create mode 100644 src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HeaderDictionaryWrapper.cs create mode 100644 src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HttpContextItemsWrapper.cs create mode 100644 src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HttpContextValue.cs create mode 100644 src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HttpRequestValue.cs create mode 100644 src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/RouteValueDictionaryWrapper.cs diff --git a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/LiquidHttpContextAccessor.cs b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/LiquidHttpContextAccessor.cs index 6f807418559..2f08eb0923b 100644 --- a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/LiquidHttpContextAccessor.cs +++ b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/LiquidHttpContextAccessor.cs @@ -3,6 +3,7 @@ namespace OrchardCore.Liquid; /// /// This is a placeholder class that allows modules to extend the `HttpContext` property in the current Liquid scope. /// +[Obsolete("This class is obsolete and will be removed in a future version.", error: true)] public class LiquidHttpContextAccessor { } diff --git a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/LiquidRequestAccessor.cs b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/LiquidRequestAccessor.cs index ee6ca96aec3..3405a151711 100644 --- a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/LiquidRequestAccessor.cs +++ b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/LiquidRequestAccessor.cs @@ -3,6 +3,7 @@ namespace OrchardCore.Liquid; /// /// This is a placeholder class that allows modules to extend the `HttpRequest` property in the current Liquid scope. /// +[Obsolete("This class is obsolete and will be removed in a future version.", error: true)] public class LiquidRequestAccessor { } diff --git a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/TemplateOptionsConfigurations.cs b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/TemplateOptionsConfigurations.cs index ab07a60889d..ed4a2abf555 100644 --- a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/TemplateOptionsConfigurations.cs +++ b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/TemplateOptionsConfigurations.cs @@ -44,58 +44,9 @@ public void Configure(TemplateOptions options) options.Scope.SetValue("Environment", new HostingEnvironmentValue(_hostEnvironment)); - options.Scope.SetValue("Request", new ObjectValue(new LiquidRequestAccessor())); - options.MemberAccessStrategy.Register((obj, name, ctx) => - { - var request = ((LiquidTemplateContext)ctx).Services.GetRequiredService().HttpContext?.Request; - if (request != null) - { - return name switch - { - nameof(HttpRequest.QueryString) => new StringValue(request.QueryString.Value), - nameof(HttpRequest.ContentType) => new StringValue(request.ContentType), - nameof(HttpRequest.ContentLength) => NumberValue.Create(request.ContentLength ?? 0), - nameof(HttpRequest.Cookies) => new ObjectValue(new CookieCollectionWrapper(request.Cookies)), - nameof(HttpRequest.Headers) => new ObjectValue(new HeaderDictionaryWrapper(request.Headers)), - nameof(HttpRequest.Query) => new ObjectValue(new QueryCollection(request.Query.ToDictionary(kv => kv.Key, kv => kv.Value))), - nameof(HttpRequest.Form) => request.HasFormContentType ? (FluidValue)new ObjectValue(request.Form) : NilValue.Instance, - nameof(HttpRequest.Protocol) => new StringValue(request.Protocol), - nameof(HttpRequest.Path) => new StringValue(request.Path.Value), - nameof(HttpRequest.PathBase) => new StringValue(request.PathBase.Value), - nameof(HttpRequest.Host) => new StringValue(request.Host.Value), - nameof(HttpRequest.IsHttps) => BooleanValue.Create(request.IsHttps), - nameof(HttpRequest.Scheme) => new StringValue(request.Scheme), - nameof(HttpRequest.Method) => new StringValue(request.Method), - nameof(HttpRequest.RouteValues) => new ObjectValue(new RouteValueDictionaryWrapper(request.RouteValues)), - - // Provides correct escaping to reconstruct a request or redirect URI. - "UriHost" => new StringValue(request.Host.ToUriComponent(), encode: false), - "UriPath" => new StringValue(request.Path.ToUriComponent(), encode: false), - "UriPathBase" => new StringValue(request.PathBase.ToUriComponent(), encode: false), - "UriQueryString" => new StringValue(request.QueryString.ToUriComponent(), encode: false), - - _ => NilValue.Instance - }; - } - - return NilValue.Instance; - }); - - options.Scope.SetValue("HttpContext", new ObjectValue(new LiquidHttpContextAccessor())); - options.MemberAccessStrategy.Register((obj, name, ctx) => - { - var httpContext = ((LiquidTemplateContext)ctx).Services.GetRequiredService().HttpContext; - if (httpContext != null) - { - return name switch - { - nameof(HttpContext.Items) => new ObjectValue(new HttpContextItemsWrapper(httpContext.Items)), - _ => NilValue.Instance - }; - } + options.Scope.SetValue("Request", new HttpRequestValue()); - return NilValue.Instance; - }); + options.Scope.SetValue("HttpContext", new HttpContextValue()); options.MemberAccessStrategy.Register((forms, name) => { @@ -113,44 +64,4 @@ public void Configure(TemplateOptions options) options.MemberAccessStrategy.Register((headers, name) => headers.HeaderDictionary[name].ToArray()); options.MemberAccessStrategy.Register((headers, name) => headers.RouteValueDictionary[name]); } - - private sealed class CookieCollectionWrapper - { - public readonly IRequestCookieCollection RequestCookieCollection; - - public CookieCollectionWrapper(IRequestCookieCollection requestCookieCollection) - { - RequestCookieCollection = requestCookieCollection; - } - } - - private sealed class HeaderDictionaryWrapper - { - public readonly IHeaderDictionary HeaderDictionary; - - public HeaderDictionaryWrapper(IHeaderDictionary headerDictionary) - { - HeaderDictionary = headerDictionary; - } - } - - private sealed class HttpContextItemsWrapper - { - public readonly IDictionary Items; - - public HttpContextItemsWrapper(IDictionary items) - { - Items = items; - } - } - - private sealed class RouteValueDictionaryWrapper - { - public readonly IReadOnlyDictionary RouteValueDictionary; - - public RouteValueDictionaryWrapper(IReadOnlyDictionary routeValueDictionary) - { - RouteValueDictionary = routeValueDictionary; - } - } } diff --git a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/CookieCollectionWrapper.cs b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/CookieCollectionWrapper.cs new file mode 100644 index 00000000000..354de2de7c4 --- /dev/null +++ b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/CookieCollectionWrapper.cs @@ -0,0 +1,13 @@ +using Microsoft.AspNetCore.Http; + +namespace OrchardCore.DisplayManagement.Liquid.Values; + +internal sealed class CookieCollectionWrapper +{ + public readonly IRequestCookieCollection RequestCookieCollection; + + public CookieCollectionWrapper(IRequestCookieCollection requestCookieCollection) + { + RequestCookieCollection = requestCookieCollection; + } +} diff --git a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HeaderDictionaryWrapper.cs b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HeaderDictionaryWrapper.cs new file mode 100644 index 00000000000..1938c5b6577 --- /dev/null +++ b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HeaderDictionaryWrapper.cs @@ -0,0 +1,13 @@ +using Microsoft.AspNetCore.Http; + +namespace OrchardCore.DisplayManagement.Liquid.Values; + +internal sealed class HeaderDictionaryWrapper +{ + public readonly IHeaderDictionary HeaderDictionary; + + public HeaderDictionaryWrapper(IHeaderDictionary headerDictionary) + { + HeaderDictionary = headerDictionary; + } +} diff --git a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HttpContextItemsWrapper.cs b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HttpContextItemsWrapper.cs new file mode 100644 index 00000000000..eb34deb5044 --- /dev/null +++ b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HttpContextItemsWrapper.cs @@ -0,0 +1,11 @@ +namespace OrchardCore.DisplayManagement.Liquid.Values; + +internal sealed class HttpContextItemsWrapper +{ + public readonly IDictionary Items; + + public HttpContextItemsWrapper(IDictionary items) + { + Items = items; + } +} diff --git a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HttpContextValue.cs b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HttpContextValue.cs new file mode 100644 index 00000000000..84880439fae --- /dev/null +++ b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HttpContextValue.cs @@ -0,0 +1,66 @@ +using System.Globalization; +using System.Text.Encodings.Web; +using Fluid; +using Fluid.Values; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using OrchardCore.Liquid; + +namespace OrchardCore.DisplayManagement.Liquid.Values; + +internal sealed class HttpContextValue : FluidValue +{ + public override FluidValues Type => FluidValues.Object; + + public override bool Equals(FluidValue other) + { + if (other is null) + { + return false; + } + + return other is HttpContextValue; + } + + public override bool ToBooleanValue() => true; + + public override decimal ToNumberValue() => 0; + + public override object ToObjectValue() => null; + + public override string ToStringValue() => "HttpContext"; + +#pragma warning disable CS0672 // Member overrides obsolete member + public override void WriteTo(TextWriter writer, TextEncoder encoder, CultureInfo cultureInfo) +#pragma warning restore CS0672 // Member overrides obsolete member + => writer.Write(ToStringValue()); + + public async override ValueTask WriteToAsync(TextWriter writer, TextEncoder encoder, CultureInfo cultureInfo) + => await writer.WriteAsync(ToStringValue()); + + public override ValueTask GetValueAsync(string name, TemplateContext context) + { + var httpContext = GetHttpContext(context); + + if (httpContext is null) + { + return new ValueTask(NilValue.Instance); + } + + return name switch + { + nameof(HttpContext.Items) => new ObjectValue(new HttpContextItemsWrapper(httpContext.Items)), + _ => NilValue.Instance + }; + } + + private static HttpContext GetHttpContext(TemplateContext context) + { + var ctx = context as LiquidTemplateContext + ?? throw new InvalidOperationException($"An implementation of '{nameof(LiquidTemplateContext)}' is required"); + + var httpContextAccessor = ctx.Services.GetRequiredService(); + + return httpContextAccessor.HttpContext; + } +} diff --git a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HttpRequestValue.cs b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HttpRequestValue.cs new file mode 100644 index 00000000000..6a5e1dd7fa9 --- /dev/null +++ b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HttpRequestValue.cs @@ -0,0 +1,89 @@ +using System.Globalization; +using System.Text.Encodings.Web; +using Fluid; +using Fluid.Values; +using Microsoft.AspNetCore.Http; +using Microsoft.Extensions.DependencyInjection; +using OrchardCore.Liquid; + +namespace OrchardCore.DisplayManagement.Liquid.Values; + +internal sealed class HttpRequestValue : FluidValue +{ + public override FluidValues Type => FluidValues.Object; + + /// + /// Creates a new instance of a for the specified HTTP request. + /// + public override bool Equals(FluidValue other) + { + if (other is null) + { + return false; + } + + return other is HttpRequestValue; + } + + public override bool ToBooleanValue() => true; + + public override decimal ToNumberValue() => 0; + + public override object ToObjectValue() => null; + + public override string ToStringValue() => "Request"; + +#pragma warning disable CS0672 // Member overrides obsolete member + public override void WriteTo(TextWriter writer, TextEncoder encoder, CultureInfo cultureInfo) +#pragma warning restore CS0672 // Member overrides obsolete member + => writer.Write(ToStringValue()); + + public async override ValueTask WriteToAsync(TextWriter writer, TextEncoder encoder, CultureInfo cultureInfo) + => await writer.WriteAsync(ToStringValue()); + + public override ValueTask GetValueAsync(string name, TemplateContext context) + { + var request = GetHttpRequest(context); + + if (request is null) + { + return new ValueTask(NilValue.Instance); + } + + return name switch + { + nameof(HttpRequest.QueryString) => new StringValue(request.QueryString.Value), + nameof(HttpRequest.ContentType) => new StringValue(request.ContentType), + nameof(HttpRequest.ContentLength) => NumberValue.Create(request.ContentLength ?? 0), + nameof(HttpRequest.Cookies) => new ObjectValue(new CookieCollectionWrapper(request.Cookies)), + nameof(HttpRequest.Headers) => new ObjectValue(new HeaderDictionaryWrapper(request.Headers)), + nameof(HttpRequest.Query) => new ObjectValue(new QueryCollection(request.Query.ToDictionary(kv => kv.Key, kv => kv.Value))), + nameof(HttpRequest.Form) => request.HasFormContentType ? (FluidValue)new ObjectValue(request.Form) : NilValue.Instance, + nameof(HttpRequest.Protocol) => new StringValue(request.Protocol), + nameof(HttpRequest.Path) => new StringValue(request.Path.Value), + nameof(HttpRequest.PathBase) => new StringValue(request.PathBase.Value), + nameof(HttpRequest.Host) => new StringValue(request.Host.Value), + nameof(HttpRequest.IsHttps) => BooleanValue.Create(request.IsHttps), + nameof(HttpRequest.Scheme) => new StringValue(request.Scheme), + nameof(HttpRequest.Method) => new StringValue(request.Method), + nameof(HttpRequest.RouteValues) => new ObjectValue(new RouteValueDictionaryWrapper(request.RouteValues)), + + // Provides correct escaping to reconstruct a request or redirect URI. + "UriHost" => new StringValue(request.Host.ToUriComponent(), encode: false), + "UriPath" => new StringValue(request.Path.ToUriComponent(), encode: false), + "UriPathBase" => new StringValue(request.PathBase.ToUriComponent(), encode: false), + "UriQueryString" => new StringValue(request.QueryString.ToUriComponent(), encode: false), + _ => ValueTask.FromResult(NilValue.Instance) + }; + } + + private static HttpRequest GetHttpRequest(TemplateContext context) + { + var ctx = context as LiquidTemplateContext + ?? throw new InvalidOperationException($"An implementation of '{nameof(LiquidTemplateContext)}' is required"); + + var httpContext = ctx.Services.GetRequiredService().HttpContext; + + return httpContext.Request; + } +} diff --git a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/RouteValueDictionaryWrapper.cs b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/RouteValueDictionaryWrapper.cs new file mode 100644 index 00000000000..fc9f6e1d38b --- /dev/null +++ b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/RouteValueDictionaryWrapper.cs @@ -0,0 +1,11 @@ +namespace OrchardCore.DisplayManagement.Liquid.Values; + +internal sealed class RouteValueDictionaryWrapper +{ + public readonly IReadOnlyDictionary RouteValueDictionary; + + public RouteValueDictionaryWrapper(IReadOnlyDictionary routeValueDictionary) + { + RouteValueDictionary = routeValueDictionary; + } +} From 86516ea6752e0023a53457becf77e6a9b544d723 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Ros?= Date: Sat, 9 Nov 2024 16:53:57 -0800 Subject: [PATCH 03/63] Format json document in test (#16983) --- .../Apis/Lucene/LuceneQueryTests.cs | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/test/OrchardCore.Tests/Apis/Lucene/LuceneQueryTests.cs b/test/OrchardCore.Tests/Apis/Lucene/LuceneQueryTests.cs index 038df8138c2..2129fbeb40e 100644 --- a/test/OrchardCore.Tests/Apis/Lucene/LuceneQueryTests.cs +++ b/test/OrchardCore.Tests/Apis/Lucene/LuceneQueryTests.cs @@ -130,14 +130,34 @@ public async Task TwoWildcardQueriesWithBoostHasResults() // Should find articles with "Orchard" in the title var index = "ArticleIndex"; - // { "from": 0, "size": 10, "query":{ "bool": { "should": [ { "wildcard": { "Content.ContentItem.DisplayText.Normalized": { "value": "orch*", "boost": 2 } } },{ "wildcard": { "Content.BodyAspect.Body": { "value": "orchar*", "boost": 5 } } } ] } } } - var query = - "{ \"from\": 0, \"size\": 10, \"query\":" + - "{ \"bool\": { \"should\": [ " + - "{ \"wildcard\": { \"Content.ContentItem.DisplayText.Normalized\": { \"value\": \"orch*\", \"boost\": 2 } } }," + - "{ \"wildcard\": { \"Content.BodyAspect.Body\": { \"value\": \"orchar*\", \"boost\": 5 } } }" + - "] } } }"; - + var query = """ + { + "from": 0, + "size": 10, + "query": { + "bool": { + "should": [ + { + "wildcard": { + "Content.ContentItem.DisplayText.Normalized": { + "value": "orch*", + "boost": 2 + } + } + }, + { + "wildcard": { + "Content.BodyAspect.Body": { + "value": "orchar*", + "boost": 5 + } + } + } + ] + } + } + } + """; var content = await context.Client.GetAsync($"api/lucene/content?indexName={index}&query={query}"); var queryResults = await content.Content.ReadAsAsync(); var contentItems = queryResults.Items.Select(x => JObject.FromObject(x).Deserialize()); From 5e934c7db85db2abb5b03fc6801bd986240b4ac6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Ros?= Date: Mon, 11 Nov 2024 07:32:16 -0800 Subject: [PATCH 04/63] Port suggestions from net9.0 branch (#16984) --- Directory.Packages.props | 33 +++++++++++++++---- global.json | 2 +- .../OrchardCore.Cms.Web.csproj | 3 +- .../OrchardCore.AdminDashboard/Migrations.cs | 1 - .../OrchardCore.Alias/Startup.cs | 1 - .../OrchardCore.Autoroute/Startup.cs | 1 - .../OrchardCore.Media/Recipes/MediaStep.cs | 1 - .../AzureADStartup.cs | 1 - .../OpenIdServerDeploymentSource.cs | 1 - .../OpenIdValidationDeploymentSource.cs | 2 +- .../OrchardCore.OpenId/Startup.cs | 1 - .../QueryBasedContentDeploymentSource.cs | 4 +-- .../Sql/Controllers/AdminController.cs | 1 - .../Migrations/RolesMigrations.cs | 2 +- .../Controllers/AdminController.cs | 1 - .../Controllers/AdminController.cs | 1 - .../Deployment/ThemesDeploymentSource.cs | 1 - .../Drivers/UrlRedirectRuleDisplayDriver.cs | 2 +- .../OrchardCore.Mvc.Web.csproj | 1 + .../DeploymentSourceBase.cs | 2 +- .../TemplateOptionsConfigurations.cs | 2 -- .../Values/CultureValue.cs | 2 +- .../Values/HostingEnvironmentValue.cs | 2 +- .../Values/HttpContextValue.cs | 2 +- .../Values/HttpRequestValue.cs | 2 +- .../Views/ShapeResult.cs | 2 +- .../Extensions/OpenIdExtensions.cs | 1 - .../Services/ElasticIndexManager.cs | 4 +-- .../Models/RewriteValidateResult.cs | 2 +- .../Handlers/UrlRedirectRuleHandler.cs | 2 +- .../Services/RewriteOptionsConfiguration.cs | 2 +- .../DocumentSystemTextJsonOutputFormatter.cs | 2 +- .../reference/modules/Workflows/README.md | 2 +- .../OrchardCore.Abstractions.Tests.csproj | 2 +- .../OrchardCore.Benchmarks.csproj | 2 +- .../OrchardCore.Application.Pages.csproj | 1 + .../Orchard.Queries/SqlParserTests.cs | 4 +-- .../OrchardCore.Tests.csproj | 2 +- .../DefaultDocumentSerializerTests.cs | 2 +- 39 files changed, 55 insertions(+), 47 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 08c3a35cfb1..515927ede00 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -39,7 +39,6 @@ - + + @@ -114,14 +117,30 @@ - + + + + + + + + + + + + + diff --git a/global.json b/global.json index d071d65668d..c28a09796d4 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { "version": "8.0.101", - "rollForward": "latestFeature" + "rollForward": "latestMajor" } } diff --git a/src/OrchardCore.Cms.Web/OrchardCore.Cms.Web.csproj b/src/OrchardCore.Cms.Web/OrchardCore.Cms.Web.csproj index 3ee9b1f0478..c1d1edec217 100644 --- a/src/OrchardCore.Cms.Web/OrchardCore.Cms.Web.csproj +++ b/src/OrchardCore.Cms.Web/OrchardCore.Cms.Web.csproj @@ -1,4 +1,4 @@ - + @@ -13,6 +13,7 @@ 2cfccf50-2ae4-4017-bbd7-a0e453cbf713 + true diff --git a/src/OrchardCore.Modules/OrchardCore.AdminDashboard/Migrations.cs b/src/OrchardCore.Modules/OrchardCore.AdminDashboard/Migrations.cs index 0f775b80c78..823acb07a7a 100644 --- a/src/OrchardCore.Modules/OrchardCore.AdminDashboard/Migrations.cs +++ b/src/OrchardCore.Modules/OrchardCore.AdminDashboard/Migrations.cs @@ -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; diff --git a/src/OrchardCore.Modules/OrchardCore.Alias/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Alias/Startup.cs index c08f6df7e85..100405e16b5 100644 --- a/src/OrchardCore.Modules/OrchardCore.Alias/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Alias/Startup.cs @@ -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; diff --git a/src/OrchardCore.Modules/OrchardCore.Autoroute/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Autoroute/Startup.cs index c500a1ca040..e537e8fbe35 100644 --- a/src/OrchardCore.Modules/OrchardCore.Autoroute/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Autoroute/Startup.cs @@ -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; diff --git a/src/OrchardCore.Modules/OrchardCore.Media/Recipes/MediaStep.cs b/src/OrchardCore.Modules/OrchardCore.Media/Recipes/MediaStep.cs index 9550cf37ba0..5952895888e 100644 --- a/src/OrchardCore.Modules/OrchardCore.Media/Recipes/MediaStep.cs +++ b/src/OrchardCore.Modules/OrchardCore.Media/Recipes/MediaStep.cs @@ -1,4 +1,3 @@ -using System.Text; using System.Text.Json.Nodes; using Microsoft.Extensions.FileProviders; using Microsoft.Extensions.Localization; diff --git a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/AzureADStartup.cs b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/AzureADStartup.cs index 45d0933e8c9..a7f963ad9b9 100644 --- a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/AzureADStartup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/AzureADStartup.cs @@ -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; diff --git a/src/OrchardCore.Modules/OrchardCore.OpenId/Deployment/OpenIdServerDeploymentSource.cs b/src/OrchardCore.Modules/OrchardCore.OpenId/Deployment/OpenIdServerDeploymentSource.cs index db7f2374f0b..47a7047f60d 100644 --- a/src/OrchardCore.Modules/OrchardCore.OpenId/Deployment/OpenIdServerDeploymentSource.cs +++ b/src/OrchardCore.Modules/OrchardCore.OpenId/Deployment/OpenIdServerDeploymentSource.cs @@ -2,7 +2,6 @@ using OrchardCore.Deployment; using OrchardCore.OpenId.Recipes; using OrchardCore.OpenId.Services; -using OrchardCore.OpenId.Settings; namespace OrchardCore.OpenId.Deployment; diff --git a/src/OrchardCore.Modules/OrchardCore.OpenId/Deployment/OpenIdValidationDeploymentSource.cs b/src/OrchardCore.Modules/OrchardCore.OpenId/Deployment/OpenIdValidationDeploymentSource.cs index f0a782f5a10..ec42a95cfe5 100644 --- a/src/OrchardCore.Modules/OrchardCore.OpenId/Deployment/OpenIdValidationDeploymentSource.cs +++ b/src/OrchardCore.Modules/OrchardCore.OpenId/Deployment/OpenIdValidationDeploymentSource.cs @@ -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), }); } diff --git a/src/OrchardCore.Modules/OrchardCore.OpenId/Startup.cs b/src/OrchardCore.Modules/OrchardCore.OpenId/Startup.cs index fa8382b3eb8..24f59367b42 100644 --- a/src/OrchardCore.Modules/OrchardCore.OpenId/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.OpenId/Startup.cs @@ -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; diff --git a/src/OrchardCore.Modules/OrchardCore.Queries/Deployment/QueryBasedContentDeploymentSource.cs b/src/OrchardCore.Modules/OrchardCore.Queries/Deployment/QueryBasedContentDeploymentSource.cs index 615cf61bfb8..522002423f5 100644 --- a/src/OrchardCore.Modules/OrchardCore.Queries/Deployment/QueryBasedContentDeploymentSource.cs +++ b/src/OrchardCore.Modules/OrchardCore.Queries/Deployment/QueryBasedContentDeploymentSource.cs @@ -75,13 +75,13 @@ private static bool TryDeserializeParameters(string parameters, out Dictionary>(parameters) ?? []; - + return true; } catch (JsonException) { queryParameters = []; - + return false; } } diff --git a/src/OrchardCore.Modules/OrchardCore.Queries/Sql/Controllers/AdminController.cs b/src/OrchardCore.Modules/OrchardCore.Queries/Sql/Controllers/AdminController.cs index 97bf13907f4..fdd29cc430d 100644 --- a/src/OrchardCore.Modules/OrchardCore.Queries/Sql/Controllers/AdminController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Queries/Sql/Controllers/AdminController.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using System.Text; using System.Text.Json; using Dapper; using Fluid; diff --git a/src/OrchardCore.Modules/OrchardCore.Roles/Migrations/RolesMigrations.cs b/src/OrchardCore.Modules/OrchardCore.Roles/Migrations/RolesMigrations.cs index b9bd4bf00b9..023f8319221 100644 --- a/src/OrchardCore.Modules/OrchardCore.Roles/Migrations/RolesMigrations.cs +++ b/src/OrchardCore.Modules/OrchardCore.Roles/Migrations/RolesMigrations.cs @@ -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) { diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Controllers/AdminController.cs b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Controllers/AdminController.cs index 12419aeed3d..bed76db348b 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Controllers/AdminController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Controllers/AdminController.cs @@ -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; diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Controllers/AdminController.cs b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Controllers/AdminController.cs index c8245412ab2..ee3ae49ade7 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Controllers/AdminController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Controllers/AdminController.cs @@ -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; diff --git a/src/OrchardCore.Modules/OrchardCore.Themes/Deployment/ThemesDeploymentSource.cs b/src/OrchardCore.Modules/OrchardCore.Themes/Deployment/ThemesDeploymentSource.cs index e50bcb58df4..ea8ec2c0b23 100644 --- a/src/OrchardCore.Modules/OrchardCore.Themes/Deployment/ThemesDeploymentSource.cs +++ b/src/OrchardCore.Modules/OrchardCore.Themes/Deployment/ThemesDeploymentSource.cs @@ -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; diff --git a/src/OrchardCore.Modules/OrchardCore.UrlRewriting/Drivers/UrlRedirectRuleDisplayDriver.cs b/src/OrchardCore.Modules/OrchardCore.UrlRewriting/Drivers/UrlRedirectRuleDisplayDriver.cs index 24e9e95249c..e9656dfa259 100644 --- a/src/OrchardCore.Modules/OrchardCore.UrlRewriting/Drivers/UrlRedirectRuleDisplayDriver.cs +++ b/src/OrchardCore.Modules/OrchardCore.UrlRewriting/Drivers/UrlRedirectRuleDisplayDriver.cs @@ -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(metadata.RedirectType) ? metadata.RedirectType : RedirectType.Found; diff --git a/src/OrchardCore.Mvc.Web/OrchardCore.Mvc.Web.csproj b/src/OrchardCore.Mvc.Web/OrchardCore.Mvc.Web.csproj index 716ba834d14..5a1b32b788e 100644 --- a/src/OrchardCore.Mvc.Web/OrchardCore.Mvc.Web.csproj +++ b/src/OrchardCore.Mvc.Web/OrchardCore.Mvc.Web.csproj @@ -5,6 +5,7 @@ InProcess enable enable + true diff --git a/src/OrchardCore/OrchardCore.Deployment.Abstractions/DeploymentSourceBase.cs b/src/OrchardCore/OrchardCore.Deployment.Abstractions/DeploymentSourceBase.cs index 7b2dd5050e4..1bbc7d31412 100644 --- a/src/OrchardCore/OrchardCore.Deployment.Abstractions/DeploymentSourceBase.cs +++ b/src/OrchardCore/OrchardCore.Deployment.Abstractions/DeploymentSourceBase.cs @@ -4,7 +4,7 @@ namespace OrchardCore.Deployment; /// Represents a base class for deployment source. /// /// The deployment step type. -public abstract class DeploymentSourceBase : IDeploymentSource +public abstract class DeploymentSourceBase : IDeploymentSource where TStep : DeploymentStep { /// diff --git a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/TemplateOptionsConfigurations.cs b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/TemplateOptionsConfigurations.cs index ed4a2abf555..bb9f2a639ae 100644 --- a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/TemplateOptionsConfigurations.cs +++ b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/TemplateOptionsConfigurations.cs @@ -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; diff --git a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/CultureValue.cs b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/CultureValue.cs index a8ab8113a70..f234d98cb59 100644 --- a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/CultureValue.cs +++ b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/CultureValue.cs @@ -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 GetValueAsync(string name, TemplateContext context) diff --git a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HostingEnvironmentValue.cs b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HostingEnvironmentValue.cs index 67b51e813d1..cb02e3dc9f6 100644 --- a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HostingEnvironmentValue.cs +++ b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HostingEnvironmentValue.cs @@ -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 GetValueAsync(string name, TemplateContext context) diff --git a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HttpContextValue.cs b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HttpContextValue.cs index 84880439fae..e0b0bc866e5 100644 --- a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HttpContextValue.cs +++ b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HttpContextValue.cs @@ -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 GetValueAsync(string name, TemplateContext context) diff --git a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HttpRequestValue.cs b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HttpRequestValue.cs index 6a5e1dd7fa9..370546fa5c6 100644 --- a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HttpRequestValue.cs +++ b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/Values/HttpRequestValue.cs @@ -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 GetValueAsync(string name, TemplateContext context) diff --git a/src/OrchardCore/OrchardCore.DisplayManagement/Views/ShapeResult.cs b/src/OrchardCore/OrchardCore.DisplayManagement/Views/ShapeResult.cs index a99ba962e88..6cb28855904 100644 --- a/src/OrchardCore/OrchardCore.DisplayManagement/Views/ShapeResult.cs +++ b/src/OrchardCore/OrchardCore.DisplayManagement/Views/ShapeResult.cs @@ -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)) { diff --git a/src/OrchardCore/OrchardCore.OpenId.Core/Extensions/OpenIdExtensions.cs b/src/OrchardCore/OrchardCore.OpenId.Core/Extensions/OpenIdExtensions.cs index 9909d23ff67..95acb2e5cd4 100644 --- a/src/OrchardCore/OrchardCore.OpenId.Core/Extensions/OpenIdExtensions.cs +++ b/src/OrchardCore/OrchardCore.OpenId.Core/Extensions/OpenIdExtensions.cs @@ -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; diff --git a/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Services/ElasticIndexManager.cs b/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Services/ElasticIndexManager.cs index f6a1ea5256e..09c7177177a 100644 --- a/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Services/ElasticIndexManager.cs +++ b/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Services/ElasticIndexManager.cs @@ -42,7 +42,7 @@ public sealed class ElasticIndexManager { ElasticsearchConstants.StopAnalyzer, () => new StopAnalyzer() }, }; - private List _tokenFilterNames = new List() + private readonly List _tokenFilterNames = new List() { "asciifolding", "common_grams", @@ -457,7 +457,7 @@ public async Task CreateIndexAsync(ElasticIndexSettings elasticIndexSettin { var analyzer = CreateAnalyzer(analyzerProperties); analysisDescriptor.Analyzers(a => a.UserDefined(analyzerName, analyzer)); - } + } indexSettingsDescriptor = new IndexSettingsDescriptor(); indexSettingsDescriptor.Analysis(an => analysisDescriptor); diff --git a/src/OrchardCore/OrchardCore.UrlRewriting.Abstractions/Models/RewriteValidateResult.cs b/src/OrchardCore/OrchardCore.UrlRewriting.Abstractions/Models/RewriteValidateResult.cs index 593d80f0a3b..3ca5d086683 100644 --- a/src/OrchardCore/OrchardCore.UrlRewriting.Abstractions/Models/RewriteValidateResult.cs +++ b/src/OrchardCore/OrchardCore.UrlRewriting.Abstractions/Models/RewriteValidateResult.cs @@ -6,7 +6,7 @@ public class RewriteValidateResult { private readonly List _errors = []; - public IReadOnlyList Errors + public IReadOnlyList Errors => _errors; /// diff --git a/src/OrchardCore/OrchardCore.UrlRewriting.Core/Handlers/UrlRedirectRuleHandler.cs b/src/OrchardCore/OrchardCore.UrlRewriting.Core/Handlers/UrlRedirectRuleHandler.cs index f73a21ebb77..46c71fbd04a 100644 --- a/src/OrchardCore/OrchardCore.UrlRewriting.Core/Handlers/UrlRedirectRuleHandler.cs +++ b/src/OrchardCore/OrchardCore.UrlRewriting.Core/Handlers/UrlRedirectRuleHandler.cs @@ -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(metadata.RedirectType)) { metadata.RedirectType = RedirectType.Found; } diff --git a/src/OrchardCore/OrchardCore.UrlRewriting.Core/Services/RewriteOptionsConfiguration.cs b/src/OrchardCore/OrchardCore.UrlRewriting.Core/Services/RewriteOptionsConfiguration.cs index 2ca6d14e6de..3f6b51e59d8 100644 --- a/src/OrchardCore/OrchardCore.UrlRewriting.Core/Services/RewriteOptionsConfiguration.cs +++ b/src/OrchardCore/OrchardCore.UrlRewriting.Core/Services/RewriteOptionsConfiguration.cs @@ -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)); } } diff --git a/src/OrchardCore/OrchardCore/Extensions/DocumentSystemTextJsonOutputFormatter.cs b/src/OrchardCore/OrchardCore/Extensions/DocumentSystemTextJsonOutputFormatter.cs index 0bcc7b56a1a..8f7c4fd5b53 100644 --- a/src/OrchardCore/OrchardCore/Extensions/DocumentSystemTextJsonOutputFormatter.cs +++ b/src/OrchardCore/OrchardCore/Extensions/DocumentSystemTextJsonOutputFormatter.cs @@ -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); } diff --git a/src/docs/reference/modules/Workflows/README.md b/src/docs/reference/modules/Workflows/README.md index 415ab84566c..9252e5e7246 100644 --- a/src/docs/reference/modules/Workflows/README.md +++ b/src/docs/reference/modules/Workflows/README.md @@ -416,7 +416,7 @@ public abstract class ActivityDisplayDriver : Activit return Initialize(_editShapeType, viewModel => EditActivityAsync(activity, viewModel)).Location("Content"); } - public async override Task UpdateAsync(TActivity activity, UpdateEditorContext context) + public override async Task UpdateAsync(TActivity activity, UpdateEditorContext context) { var viewModel = new TEditViewModel(); if (await context.Updater.TryUpdateModelAsync(viewModel, Prefix)) diff --git a/test/OrchardCore.Abstractions.Tests/OrchardCore.Abstractions.Tests.csproj b/test/OrchardCore.Abstractions.Tests/OrchardCore.Abstractions.Tests.csproj index 8e5f74743d5..7ed9f49c099 100644 --- a/test/OrchardCore.Abstractions.Tests/OrchardCore.Abstractions.Tests.csproj +++ b/test/OrchardCore.Abstractions.Tests/OrchardCore.Abstractions.Tests.csproj @@ -4,7 +4,7 @@ $(CommonTargetFrameworks) OrchardCore - $(NoWarn);CA1707 + $(NoWarn);CA1707;EnableGenerateDocumentationFile diff --git a/test/OrchardCore.Benchmarks/OrchardCore.Benchmarks.csproj b/test/OrchardCore.Benchmarks/OrchardCore.Benchmarks.csproj index 06bc71b49d6..b02ee297639 100644 --- a/test/OrchardCore.Benchmarks/OrchardCore.Benchmarks.csproj +++ b/test/OrchardCore.Benchmarks/OrchardCore.Benchmarks.csproj @@ -6,7 +6,7 @@ false Exe - $(NoWarn);CA1707 + $(NoWarn);CA1707;EnableGenerateDocumentationFile diff --git a/test/OrchardCore.Tests.Pages/OrchardCore.Application.Pages/OrchardCore.Application.Pages.csproj b/test/OrchardCore.Tests.Pages/OrchardCore.Application.Pages/OrchardCore.Application.Pages.csproj index c875faed8be..45ae0b7c3ee 100644 --- a/test/OrchardCore.Tests.Pages/OrchardCore.Application.Pages/OrchardCore.Application.Pages.csproj +++ b/test/OrchardCore.Tests.Pages/OrchardCore.Application.Pages/OrchardCore.Application.Pages.csproj @@ -7,6 +7,7 @@ $(CommonTargetFrameworks) InProcess false + $(NoWarn);EnableGenerateDocumentationFile diff --git a/test/OrchardCore.Tests/Orchard.Queries/SqlParserTests.cs b/test/OrchardCore.Tests/Orchard.Queries/SqlParserTests.cs index ec7850a5479..db6456d6210 100644 --- a/test/OrchardCore.Tests/Orchard.Queries/SqlParserTests.cs +++ b/test/OrchardCore.Tests/Orchard.Queries/SqlParserTests.cs @@ -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)); diff --git a/test/OrchardCore.Tests/OrchardCore.Tests.csproj b/test/OrchardCore.Tests/OrchardCore.Tests.csproj index 4e6ec67115d..dd8e9789def 100644 --- a/test/OrchardCore.Tests/OrchardCore.Tests.csproj +++ b/test/OrchardCore.Tests/OrchardCore.Tests.csproj @@ -3,7 +3,7 @@ $(CommonTargetFrameworks) - $(NoWarn);CA1707 + $(NoWarn);CA1707;EnableGenerateDocumentationFile diff --git a/test/OrchardCore.Tests/Serializers/DefaultDocumentSerializerTests.cs b/test/OrchardCore.Tests/Serializers/DefaultDocumentSerializerTests.cs index a1bbe4d46b9..9788f597b58 100644 --- a/test/OrchardCore.Tests/Serializers/DefaultDocumentSerializerTests.cs +++ b/test/OrchardCore.Tests/Serializers/DefaultDocumentSerializerTests.cs @@ -22,7 +22,7 @@ public async Task ShouldSerializeAndDeserialize() // Data should be gzipped Assert.Equal([0x1f, 0x8b], data.AsSpan().Slice(0, 2).ToArray()); - var settings2 = await serializer.DeserializeAsync(data); + var settings2 = await serializer.DeserializeAsync(data); Assert.Equal(settings.AppendVersion, settings2.AppendVersion); Assert.Equal(settings.BaseUrl, settings2.BaseUrl); From 8ff1695280ffe5777f960321e259969f5d8b4989 Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Mon, 11 Nov 2024 12:10:58 -0800 Subject: [PATCH 05/63] Fix Media Cache Handler (#16992) --- .../DefaultMediaFileStoreCacheEventHandler.cs | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/OrchardCore/OrchardCore.Media.Core/Events/DefaultMediaFileStoreCacheEventHandler.cs b/src/OrchardCore/OrchardCore.Media.Core/Events/DefaultMediaFileStoreCacheEventHandler.cs index 58d6bcf7c4b..bace86eed14 100644 --- a/src/OrchardCore/OrchardCore.Media.Core/Events/DefaultMediaFileStoreCacheEventHandler.cs +++ b/src/OrchardCore/OrchardCore.Media.Core/Events/DefaultMediaFileStoreCacheEventHandler.cs @@ -12,23 +12,11 @@ public DefaultMediaFileStoreCacheEventHandler(IMediaFileStoreCacheFileProvider m } public override Task MediaDeletedDirectoryAsync(MediaDeletedContext context) - { - _mediaFileStoreCacheFileProvider.TryDeleteDirectoryAsync(context.Path); - - return Task.CompletedTask; - } + => _mediaFileStoreCacheFileProvider.TryDeleteDirectoryAsync(context.Path); public override Task MediaDeletedFileAsync(MediaDeletedContext context) - { - _mediaFileStoreCacheFileProvider.TryDeleteFileAsync(context.Path); - - return Task.CompletedTask; - } + => _mediaFileStoreCacheFileProvider.TryDeleteFileAsync(context.Path); public override Task MediaMovedAsync(MediaMoveContext context) - { - _mediaFileStoreCacheFileProvider.TryDeleteFileAsync(context.OldPath); - - return Task.CompletedTask; - } + => _mediaFileStoreCacheFileProvider.TryDeleteFileAsync(context.OldPath); } From f2623140e1f2f07b7852068345ffe8380bc1a968 Mon Sep 17 00:00:00 2001 From: Hisham Bin Ateya Date: Tue, 12 Nov 2024 00:02:00 +0300 Subject: [PATCH 06/63] Fix deleting sub menus (#16990) --- .../OrchardCore.Menu/Controllers/AdminController.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Menu/Controllers/AdminController.cs b/src/OrchardCore.Modules/OrchardCore.Menu/Controllers/AdminController.cs index 775166950ab..400f757d4af 100644 --- a/src/OrchardCore.Modules/OrchardCore.Menu/Controllers/AdminController.cs +++ b/src/OrchardCore.Modules/OrchardCore.Menu/Controllers/AdminController.cs @@ -271,8 +271,9 @@ public async Task Delete(string menuContentItemId, string menuIte return NotFound(); } - var menuItems = menuContentAsJson[nameof(MenuItemsListPart)]?[nameof(MenuItemsListPart.MenuItems)] as JsonArray; - menuItems?.Remove(menuItem); + var menuItems = menuContentAsJson.SelectNode(menuItem.Parent.GetPath()) as JsonArray; + + menuItems.Remove(menuItem); await _contentManager.SaveDraftAsync(menu); From f12ee457e744876d4f5b04a407cd7f56b72644e9 Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Mon, 11 Nov 2024 15:30:05 -0800 Subject: [PATCH 07/63] Remove unnecessary casing (#16993) --- .../OrchardCore.Contents/Views/Admin/Display.cshtml | 6 ------ .../OrchardCore.Contents/Views/Item/Display.cshtml | 6 ------ .../OrchardCore.Contents/Views/Item/Preview.cshtml | 6 ------ 3 files changed, 18 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Views/Admin/Display.cshtml b/src/OrchardCore.Modules/OrchardCore.Contents/Views/Admin/Display.cshtml index e716ccfff53..32eceece3e6 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Views/Admin/Display.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Views/Admin/Display.cshtml @@ -1,7 +1 @@ -@using OrchardCore.ContentManagement -@using OrchardCore.Mvc.Utilities -@{ - ContentItem contentItem = Model.ContentItem; - //Html.AddPageClassNames("detail-" + contentItem.ContentType.HtmlClassify()); -} @await DisplayAsync(Model) diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Views/Item/Display.cshtml b/src/OrchardCore.Modules/OrchardCore.Contents/Views/Item/Display.cshtml index 714da684a66..32eceece3e6 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Views/Item/Display.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Views/Item/Display.cshtml @@ -1,7 +1 @@ -@using OrchardCore.ContentManagement -@using OrchardCore.Mvc.Utilities -@{ - ContentItem contentItem = Model.ContentItem; - //Html.AddPageClassNames("detail-" + contentItem.ContentType.HtmlClassify()); -} @await DisplayAsync(Model) diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Views/Item/Preview.cshtml b/src/OrchardCore.Modules/OrchardCore.Contents/Views/Item/Preview.cshtml index 5388b098096..32eceece3e6 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Views/Item/Preview.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Views/Item/Preview.cshtml @@ -1,7 +1 @@ -@using OrchardCore.ContentManagement -@using OrchardCore.Mvc.Utilities -@{ - ContentItem contentItem = Model.ContentItem; - //Html.AddPageClassNames("preview", "detail-" + contentItem.ContentType.HtmlClassify()); -} @await DisplayAsync(Model) From 34c7a265227bfa936f01ffb11f6c21bef2e0e8ba Mon Sep 17 00:00:00 2001 From: Hisham Bin Ateya Date: Tue, 12 Nov 2024 02:46:49 +0300 Subject: [PATCH 08/63] Use AddPermissionProvider & AddNavigationProvider in OpenID (#16960) --- .../OrchardCore.ContentPreview/Startup.cs | 2 +- .../OrchardCore.Cors/Startup.cs | 3 +-- .../OrchardCore.Diagnostics/Startup.cs | 2 +- .../OrchardCore.Facebook/StartupLogin.cs | 15 +++++---------- .../OrchardCore.GitHub/Startup.cs | 13 +++++-------- .../GoogleAuthenticationStartup.cs | 14 ++++++-------- .../MicrosoftAccountStartup.cs | 2 +- .../OrchardCore.OpenId/Startup.cs | 8 ++------ .../OrchardCore.ReverseProxy/Startup.cs | 3 +-- .../OrchardCore.Twitter/Startup.cs | 14 ++++++-------- .../ServiceCollectionExtensions.cs | 3 ++- .../OrchardCoreBuilderExtensions.cs | 8 ++------ .../OrchardCoreBuilderExtensions.cs | 3 +-- .../Documents/OrchardCoreBuilderExtensions.cs | 4 +--- .../Entities/ServiceCollectionExtensions.cs | 3 ++- .../ModularPageMvcCoreBuilderExtensions.cs | 8 +++----- src/OrchardCore/OrchardCore.Mvc.Core/Startup.cs | 9 +++------ .../Extensions/OpenIdExtensions.cs | 3 +-- 18 files changed, 44 insertions(+), 73 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.ContentPreview/Startup.cs b/src/OrchardCore.Modules/OrchardCore.ContentPreview/Startup.cs index 7f4052e5c2b..1f53c634d1d 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentPreview/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentPreview/Startup.cs @@ -28,6 +28,6 @@ public override void ConfigureServices(IServiceCollection services) services.AddDataMigration(); services.AddScoped(); - services.TryAddEnumerable(ServiceDescriptor.Singleton()); + services.AddSingleton(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Cors/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Cors/Startup.cs index 27e88a5990b..3bf19aa4b78 100644 --- a/src/OrchardCore.Modules/OrchardCore.Cors/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Cors/Startup.cs @@ -28,7 +28,6 @@ public override void ConfigureServices(IServiceCollection services) services.AddPermissionProvider(); services.AddSingleton(); - services.TryAddEnumerable(ServiceDescriptor - .Transient, CorsOptionsConfiguration>()); + services.AddTransient, CorsOptionsConfiguration>(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Diagnostics/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Diagnostics/Startup.cs index 4bcdc5b1487..dd3937239bf 100644 --- a/src/OrchardCore.Modules/OrchardCore.Diagnostics/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Diagnostics/Startup.cs @@ -10,7 +10,7 @@ public sealed class Startup : Modules.StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.TryAddEnumerable(ServiceDescriptor.Singleton()); + services.AddSingleton(); } public override void Configure(IApplicationBuilder app, IEndpointRouteBuilder routes, IServiceProvider serviceProvider) diff --git a/src/OrchardCore.Modules/OrchardCore.Facebook/StartupLogin.cs b/src/OrchardCore.Modules/OrchardCore.Facebook/StartupLogin.cs index c152dca0e0d..7fc9c65f7dc 100644 --- a/src/OrchardCore.Modules/OrchardCore.Facebook/StartupLogin.cs +++ b/src/OrchardCore.Modules/OrchardCore.Facebook/StartupLogin.cs @@ -28,17 +28,12 @@ public override void ConfigureServices(IServiceCollection services) services.AddRecipeExecutionStep(); // Register the options initializers required by the Facebook handler. - services.TryAddEnumerable(new[] - { - // Orchard-specific initializers: - ServiceDescriptor.Transient, FacebookLoginConfiguration>(), - ServiceDescriptor.Transient, FacebookLoginConfiguration>(), + // Orchard-specific initializers: + services.AddTransient, FacebookLoginConfiguration>(); + services.AddTransient, FacebookLoginConfiguration>(); - // Deployment - - // Built-in initializers: - ServiceDescriptor.Transient, OAuthPostConfigureOptions>() - }); + // Built-in initializers: + services.AddTransient, OAuthPostConfigureOptions>(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.GitHub/Startup.cs b/src/OrchardCore.Modules/OrchardCore.GitHub/Startup.cs index bcca7e22c6b..6a03ca8eeec 100644 --- a/src/OrchardCore.Modules/OrchardCore.GitHub/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.GitHub/Startup.cs @@ -36,13 +36,10 @@ public override void ConfigureServices(IServiceCollection services) services.AddTransient, GitHubAuthenticationSettingsConfiguration>(); // Register the options initializers required by the GitHub Handler. - services.TryAddEnumerable(new[] - { - // Orchard-specific initializers: - ServiceDescriptor.Transient, GitHubOptionsConfiguration>(), - ServiceDescriptor.Transient, GitHubOptionsConfiguration>(), - // Built-in initializers: - ServiceDescriptor.Transient, OAuthPostConfigureOptions>() - }); + // Orchard-specific initializers: + services.AddTransient, GitHubOptionsConfiguration>(); + services.AddTransient, GitHubOptionsConfiguration>(); + // Built-in initializers: + services.AddTransient, OAuthPostConfigureOptions>(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Google/GoogleAuthenticationStartup.cs b/src/OrchardCore.Modules/OrchardCore.Google/GoogleAuthenticationStartup.cs index f01e66e54a8..fca58de98b8 100644 --- a/src/OrchardCore.Modules/OrchardCore.Google/GoogleAuthenticationStartup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Google/GoogleAuthenticationStartup.cs @@ -35,14 +35,12 @@ public override void ConfigureServices(IServiceCollection services) services.AddNavigationProvider(); // Register the options initializers required by the Google Handler. - services.TryAddEnumerable(new[] - { - // Orchard-specific initializers: - ServiceDescriptor.Transient, GoogleOptionsConfiguration>(), - ServiceDescriptor.Transient, GoogleOptionsConfiguration>(), - // Built-in initializers: - ServiceDescriptor.Transient, OAuthPostConfigureOptions>() - }); + // Orchard-specific initializers: + services.AddTransient, GoogleOptionsConfiguration>(); + services.AddTransient, GoogleOptionsConfiguration>(); + + // Built-in initializers: + services.AddTransient, OAuthPostConfigureOptions>(); services.AddTransient, GoogleAuthenticationSettingsConfiguration>(); } diff --git a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/MicrosoftAccountStartup.cs b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/MicrosoftAccountStartup.cs index ba0e26b5a84..cdd1496ce80 100644 --- a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/MicrosoftAccountStartup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/MicrosoftAccountStartup.cs @@ -23,7 +23,7 @@ public sealed class MicrosoftAccountStartup : StartupBase { public override void ConfigureServices(IServiceCollection services) { - services.TryAddEnumerable(new ServiceDescriptor(typeof(IPermissionProvider), typeof(Permissions), ServiceLifetime.Scoped)); + services.AddPermissionProvider(); services.AddSingleton(); services.AddSiteDisplayDriver(); diff --git a/src/OrchardCore.Modules/OrchardCore.OpenId/Startup.cs b/src/OrchardCore.Modules/OrchardCore.OpenId/Startup.cs index 24f59367b42..0a3e41050d5 100644 --- a/src/OrchardCore.Modules/OrchardCore.OpenId/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.OpenId/Startup.cs @@ -51,12 +51,8 @@ public override void ConfigureServices(IServiceCollection services) .UseYesSql(); }); - // Note: the following services are registered using TryAddEnumerable to prevent duplicate registrations. - services.TryAddEnumerable(new[] - { - ServiceDescriptor.Scoped(), - ServiceDescriptor.Scoped(), - }); + services.AddPermissionProvider(); + services.AddNavigationProvider(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.ReverseProxy/Startup.cs b/src/OrchardCore.Modules/OrchardCore.ReverseProxy/Startup.cs index bc7d7eee61b..3d89f4b82bc 100644 --- a/src/OrchardCore.Modules/OrchardCore.ReverseProxy/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.ReverseProxy/Startup.cs @@ -32,8 +32,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddSingleton(); - services.TryAddEnumerable(ServiceDescriptor - .Transient, ForwardedHeadersOptionsConfiguration>()); + services.AddTransient, ForwardedHeadersOptionsConfiguration>(); } } diff --git a/src/OrchardCore.Modules/OrchardCore.Twitter/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Twitter/Startup.cs index 75cd10881a4..0b5206d661a 100644 --- a/src/OrchardCore.Modules/OrchardCore.Twitter/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Twitter/Startup.cs @@ -68,14 +68,12 @@ public override void ConfigureServices(IServiceCollection services) services.AddNavigationProvider(); services.AddSingleton(); services.AddSiteDisplayDriver(); + // Register the options initializers required by the Twitter Handler. - services.TryAddEnumerable(new[] - { - // Orchard-specific initializers: - ServiceDescriptor.Transient, TwitterOptionsConfiguration>(), - ServiceDescriptor.Transient, TwitterOptionsConfiguration>(), - // Built-in initializers: - ServiceDescriptor.Transient, TwitterPostConfigureOptions>() - }); + // Orchard-specific initializers: + services.AddTransient, TwitterOptionsConfiguration>(); + services.AddTransient, TwitterOptionsConfiguration>(); + // Built-in initializers: + services.AddTransient, TwitterPostConfigureOptions>(); } } diff --git a/src/OrchardCore/OrchardCore.ContentManagement.Display/ServiceCollectionExtensions.cs b/src/OrchardCore/OrchardCore.ContentManagement.Display/ServiceCollectionExtensions.cs index d57edf53eda..1b9231fbd97 100644 --- a/src/OrchardCore/OrchardCore.ContentManagement.Display/ServiceCollectionExtensions.cs +++ b/src/OrchardCore/OrchardCore.ContentManagement.Display/ServiceCollectionExtensions.cs @@ -21,7 +21,8 @@ public static IServiceCollection AddContentManagementDisplay(this IServiceCollec }); services.TryAddTransient(); - services.TryAddEnumerable(new ServiceDescriptor(typeof(IContentDisplayHandler), typeof(ContentItemDisplayCoordinator), ServiceLifetime.Scoped)); + + services.AddScoped(); services.AddScoped(); services.AddScoped(); diff --git a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/OrchardCoreBuilderExtensions.cs b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/OrchardCoreBuilderExtensions.cs index 5f1b8f28b88..7192550d572 100644 --- a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/OrchardCoreBuilderExtensions.cs +++ b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/OrchardCoreBuilderExtensions.cs @@ -27,13 +27,9 @@ public static OrchardCoreBuilder AddLiquidViews(this OrchardCoreBuilder builder) services.AddTransient, TemplateOptionsFileProviderSetup>(); - services.TryAddEnumerable( - ServiceDescriptor.Transient, - LiquidViewOptionsSetup>()); + services.AddTransient, LiquidViewOptionsSetup>(); - services.TryAddEnumerable( - ServiceDescriptor.Transient, - LiquidShapeTemplateOptionsSetup>()); + services.AddTransient, LiquidShapeTemplateOptionsSetup>(); services.AddSingleton, LiquidViewsFeatureProvider>(); services.AddScoped(); diff --git a/src/OrchardCore/OrchardCore.DisplayManagement/OrchardCoreBuilderExtensions.cs b/src/OrchardCore/OrchardCore.DisplayManagement/OrchardCoreBuilderExtensions.cs index 0c8cd7a4cd4..77ee05cb572 100644 --- a/src/OrchardCore/OrchardCore.DisplayManagement/OrchardCoreBuilderExtensions.cs +++ b/src/OrchardCore/OrchardCore.DisplayManagement/OrchardCoreBuilderExtensions.cs @@ -71,8 +71,7 @@ public static OrchardCoreBuilder AddTheming(this OrchardCoreBuilder builder) services.AddScoped(); - services.TryAddEnumerable( - ServiceDescriptor.Transient, ShapeTemplateOptionsSetup>()); + services.AddTransient, ShapeTemplateOptionsSetup>(); services.TryAddSingleton(); services.AddShapeAttributes(); diff --git a/src/OrchardCore/OrchardCore.Infrastructure/Documents/OrchardCoreBuilderExtensions.cs b/src/OrchardCore/OrchardCore.Infrastructure/Documents/OrchardCoreBuilderExtensions.cs index be4ce25df0b..af3089aabee 100644 --- a/src/OrchardCore/OrchardCore.Infrastructure/Documents/OrchardCoreBuilderExtensions.cs +++ b/src/OrchardCore/OrchardCore.Infrastructure/Documents/OrchardCoreBuilderExtensions.cs @@ -18,9 +18,7 @@ public static OrchardCoreBuilder AddDocumentManagement(this OrchardCoreBuilder b services.AddSingleton(typeof(IDocumentManager<>), typeof(DocumentManager<>)); services.AddSingleton(typeof(IVolatileDocumentManager<>), typeof(VolatileDocumentManager<>)); services.AddSingleton(typeof(IDocumentManager<,>), typeof(DocumentManager<,>)); - - services.TryAddEnumerable(ServiceDescriptor.Singleton, DocumentOptionsSetup>()); - + services.AddSingleton, DocumentOptionsSetup>(); services.AddSingleton(typeof(IDocumentEntityManager<>), typeof(DocumentEntityManager<>)); services.AddSingleton(typeof(IVolatileDocumentEntityManager<>), typeof(VolatileDocumentEntityManager<>)); services.AddSingleton(typeof(IDocumentEntityManager<,>), typeof(DocumentEntityManager<,>)); diff --git a/src/OrchardCore/OrchardCore.Infrastructure/Entities/ServiceCollectionExtensions.cs b/src/OrchardCore/OrchardCore.Infrastructure/Entities/ServiceCollectionExtensions.cs index 35dfe41e3db..6ca5eab5c08 100644 --- a/src/OrchardCore/OrchardCore.Infrastructure/Entities/ServiceCollectionExtensions.cs +++ b/src/OrchardCore/OrchardCore.Infrastructure/Entities/ServiceCollectionExtensions.cs @@ -10,7 +10,8 @@ public static class ServiceCollectionExtensions public static IServiceCollection AddIdGeneration(this IServiceCollection services) { services.TryAddSingleton(); - services.TryAddEnumerable(ServiceDescriptor.Singleton()); + services.AddSingleton(); + return services; } } diff --git a/src/OrchardCore/OrchardCore.Mvc.Core/RazorPages/ModularPageMvcCoreBuilderExtensions.cs b/src/OrchardCore/OrchardCore.Mvc.Core/RazorPages/ModularPageMvcCoreBuilderExtensions.cs index a44e27e59cd..017335e1373 100644 --- a/src/OrchardCore/OrchardCore.Mvc.Core/RazorPages/ModularPageMvcCoreBuilderExtensions.cs +++ b/src/OrchardCore/OrchardCore.Mvc.Core/RazorPages/ModularPageMvcCoreBuilderExtensions.cs @@ -18,13 +18,11 @@ public static IMvcCoreBuilder AddModularRazorPages(this IMvcCoreBuilder builder) internal static IServiceCollection AddModularRazorPages(this IServiceCollection services) { - services.TryAddEnumerable(ServiceDescriptor.Singleton()); + services.AddSingleton(); - services.TryAddEnumerable( - ServiceDescriptor.Transient, ModularPageRazorPagesOptionsSetup>()); + services.AddTransient, ModularPageRazorPagesOptionsSetup>(); - services.TryAddEnumerable( - ServiceDescriptor.Singleton()); + services.AddSingleton(); return services; } diff --git a/src/OrchardCore/OrchardCore.Mvc.Core/Startup.cs b/src/OrchardCore/OrchardCore.Mvc.Core/Startup.cs index 43b4b7b127b..3ed49d88d93 100644 --- a/src/OrchardCore/OrchardCore.Mvc.Core/Startup.cs +++ b/src/OrchardCore/OrchardCore.Mvc.Core/Startup.cs @@ -93,8 +93,7 @@ public override void ConfigureServices(IServiceCollection services) builder.AddViewLocalization(); builder.AddDataAnnotationsLocalization(); - services.TryAddEnumerable( - ServiceDescriptor.Transient, ModularRazorViewEngineOptionsSetup>()); + services.AddTransient, ModularRazorViewEngineOptionsSetup>(); if (_hostingEnvironment.IsDevelopment()) { @@ -114,8 +113,7 @@ public override void ConfigureServices(IServiceCollection services) services.AddSingleton(); } - services.TryAddEnumerable( - ServiceDescriptor.Transient, RazorCompilationOptionsSetup>()); + services.AddTransient, RazorCompilationOptionsSetup>(); services.AddSingleton(); @@ -141,7 +139,6 @@ internal static void AddMvcModuleCoreServices(IServiceCollection services) services.AddScoped(); services.AddScoped(); - services.TryAddEnumerable( - ServiceDescriptor.Singleton()); + services.AddSingleton(); } } diff --git a/src/OrchardCore/OrchardCore.OpenId.Core/Extensions/OpenIdExtensions.cs b/src/OrchardCore/OrchardCore.OpenId.Core/Extensions/OpenIdExtensions.cs index 95acb2e5cd4..f012363cec9 100644 --- a/src/OrchardCore/OrchardCore.OpenId.Core/Extensions/OpenIdExtensions.cs +++ b/src/OrchardCore/OrchardCore.OpenId.Core/Extensions/OpenIdExtensions.cs @@ -18,8 +18,7 @@ public static OpenIddictCoreBuilder AddOrchardMigrations(this OpenIddictCoreBuil { ArgumentNullException.ThrowIfNull(builder); - builder.Services.TryAddEnumerable( - ServiceDescriptor.Scoped()); + builder.Services.AddDataMigration(); // Configure support for an OpenId collection. builder.Services.Configure(o => o.Collections.Add("OpenId")); From cc059822d839eb06a4cc859811b8e9176eceb525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Ros?= Date: Mon, 11 Nov 2024 17:20:13 -0800 Subject: [PATCH 09/63] Improve functional tests (#16982) Co-authored-by: Mike Alhayek --- test/OrchardCore.Tests.Functional/Readme.md | 51 ++++- .../cypress-commands/dist/index.js | 206 +++++++++--------- .../cypress-commands/dist/index.mjs | 206 +++++++++--------- .../cypress-commands/dist/test-runner.js | 10 +- .../cypress-commands/dist/test-runner.mjs | 32 ++- .../cypress-commands/dist/utils.js | 2 - .../cypress-commands/package.json | 2 +- .../cypress-commands/src/tenants.js | 6 +- .../cypress-commands/src/test-runner.js | 26 +++ 9 files changed, 314 insertions(+), 227 deletions(-) diff --git a/test/OrchardCore.Tests.Functional/Readme.md b/test/OrchardCore.Tests.Functional/Readme.md index 26b134de0b5..178fa0536e1 100644 --- a/test/OrchardCore.Tests.Functional/Readme.md +++ b/test/OrchardCore.Tests.Functional/Readme.md @@ -1,17 +1,48 @@ -# Cypress e2e testing suite +# Cypress E2E Testing Suite -Run `npm install` followed by `npm run cms:test` to build and host Orchard and run execute the functional tests. +## Prerequisites + +To get started, install the required packages by running: + +```bash +npm install +``` + +## Available Commands + +The following commands are defined in `package.json`: + +- **Run CMS Tests**: `npm run cms:test` - Executes CMS-specific tests. *(This is usually the primary command to use)* +- **Run MVC Tests**: `npm run mvc:test` - Runs tests for MVC. +- **Run CMS Tests in UI**: `npm run cms:cypress` - Launches CMS tests in the Cypress interactive UI. +- **Run MVC Tests in UI**: `npm run mvc:cypress` - Launches MVC tests in the Cypress UI. +- **Build Orchard Core**: `npm run cms:build` - Builds or rebuilds the Orchard Core environment. +- **Host Orchard Core**: `npm run cms:host` - Starts the Orchard Core server. +- **Generate Blog Data**: `npm run gen:blog` - Generates sample data for the blog recipe. + +## Creating a New CMS Test + +### Adding a New Test Suite + +For tests requiring a fresh tenant, create a new file in `./cms-tests/cypress/integration`. Tests in this folder execute in alphabetical order. + +### Adding a Test to an Existing Suite + +To add tests to an existing scenario, open any file in `./cms-tests/cypress/integration` and include the necessary assertions. + +## Cypress Commands for Orchard Core + +Each test scenario uses custom commands tailored for Orchard Core, such as `login` and `createTenant`. These commands are located in `./cypress-commands/src`. + +To update these commands, use the `rollup` script to bundle them into the `./cypress-commands/dist` folder: -To see use the cypress user interface, run these scripts ```bash -npm run cms:clean // deletes App_Data -npm run cms:host // starts the app on port 5001 -# run this in a separate console -npm run cms:cypress // Opens the cypress ui +cd ./cypress-commands +npm run build ``` -**Note**: Tests will usually fail if not run from a clean state. +Both the `src` and `dist` folders should be included in source control. -## Test data generator +## NPM Package -To generate test data, run the `npm run gen:blog` script +The `./cypress-commands` folder contains an npm package, [cypress-orchardcore](https://www.npmjs.com/package/cypress-orchardcore), published by [@jptissot](https://github.com/jptissot). This package allows other Orchard Core applications to leverage the testing framework. diff --git a/test/OrchardCore.Tests.Functional/cypress-commands/dist/index.js b/test/OrchardCore.Tests.Functional/cypress-commands/dist/index.js index 694161ce5b4..de60819b6aa 100644 --- a/test/OrchardCore.Tests.Functional/cypress-commands/dist/index.js +++ b/test/OrchardCore.Tests.Functional/cypress-commands/dist/index.js @@ -1,155 +1,155 @@ 'use strict'; -Cypress.Commands.add("login", function ({ prefix = "" } = {}) { - const config = Cypress.config('orchard'); - cy.visit(`${prefix}/login`); - cy.get("#LoginForm_UserName").type(config.username); - cy.get("#LoginForm_Password").type(config.password); - cy.get("#LoginForm_UserName").closest('form').submit(); +Cypress.Commands.add("login", function({ prefix = ""}={}) { + const config = Cypress.config('orchard'); + cy.visit(`${prefix}/login`); + cy.get("#LoginForm_UserName").type(config.username); + cy.get("#LoginForm_Password").type(config.password); + cy.get("#LoginForm_UserName").closest('form').submit(); }); Cypress.Commands.add("visitTenantSetupPage", ({ name }) => { - cy.visit("/Admin/Tenants"); - cy.get(`#btn-setup-${name}`).click(); + cy.visit("/Admin/Tenants"); + cy.get(`#btn-setup-${name}`).click(); }); -Cypress.Commands.add("siteSetup", ({ name, setupRecipe }) => { - const config = Cypress.config('orchard'); - cy.get("#SiteName").type(name); - cy.get("body").then($body => { - const elem = $body.find("#RecipeName"); - if (elem) { - elem.val(setupRecipe); - } - const db = $body.find("#DatabaseProvider"); - if (db.length > 0 && db.val() == "") { - db.val("Sqlite"); - } - }); - cy.get("#UserName").type(config.username); - cy.get("#Email").type(config.email); - cy.get("#Password").type(config.password); - cy.get("#PasswordConfirmation").type(config.password); - cy.get("#SubmitButton").click(); +Cypress.Commands.add("siteSetup", ({ name, setupRecipe }) => { + const config = Cypress.config('orchard'); + cy.get("#SiteName").type(name); + cy.get("body").then($body => { + const elem = $body.find("#RecipeName"); + if (elem) { + elem.val(setupRecipe); + } + const db = $body.find("#DatabaseProvider"); + if(db.length > 0 && db.val() == "") { + db.val("Sqlite"); + } + }); + cy.get("#UserName").type(config.username); + cy.get("#Email").type(config.email); + cy.get("#Password").type(config.password); + cy.get("#PasswordConfirmation").type(config.password); + cy.get("#SubmitButton").click(); }); -Cypress.Commands.add('newTenant', function (tenantInfo) { - cy.login(); - cy.createTenant(tenantInfo); - cy.visitTenantSetupPage(tenantInfo); - cy.siteSetup(tenantInfo); +Cypress.Commands.add('newTenant', function(tenantInfo) { + cy.login(); + cy.createTenant(tenantInfo); + cy.visitTenantSetupPage(tenantInfo); + cy.siteSetup(tenantInfo); }); Cypress.Commands.add("createTenant", ({ name, prefix, setupRecipe, description }) => { - // We create tenants on the SaaS tenant - cy.visit("/Admin/Tenants"); - cy.btnCreateClick(); - cy.get("#Name").type(name, { force: true }); - cy.get("#Description").type(`Recipe: ${setupRecipe}. ${description || ''}`, { force: true }); - cy.get("#RequestUrlPrefix").type(prefix, { force: true }); - cy.get("#RecipeName").select(setupRecipe); - cy.get("body").then($body => { - const db = $body.find("#DatabaseProvider"); - // if a database provider is already specified by an environment variable.. leave it as is - // this assumes that if you set the provider, you also set the connectionString - if (db.length > 0 && db.val() == "") { - db.val('Sqlite'); - } else { - //set the tablePrefix to the name. - const prefix = $body.find("#TablePrefix"); - if (prefix.length > 0) { - prefix.val(name); - } + // We create tenants on the SaaS tenant + cy.visit("/Admin/Tenants"); + cy.btnCreateClick(); + cy.get("#Name").type(name, {force:true}); + cy.get("#Description").type(`Recipe: ${setupRecipe}. ${description || ''}`, {force:true}); + cy.get("#RequestUrlPrefix").type(prefix, {force:true}); + cy.get("#RecipeName").select(setupRecipe); + cy.get("body").then($body => { + const db = $body.find("#DatabaseProvider"); + // if a database provider is already specified by an environment variable.. leave it as is + // this assumes that if you set the provider, you also set the connectionString + if (db.length > 0 && db.val() == "") { + db.val('Sqlite'); + } else { + //set the tablePrefix to the name. + const prefix = $body.find("#TablePrefix"); + if(prefix.length > 0){ + prefix.val(name); } - }); - cy.btnCreateClick(); + } + }); + cy.btnCreateClick(); }); Cypress.Commands.add("runRecipe", ({ prefix }, recipeName) => { - cy.visit(`${prefix}/Admin/Recipes`); - cy.get(`#btn-run-${recipeName}`).click(); - cy.btnModalOkClick(); + cy.visit(`${prefix}/Admin/Recipes`); + cy.get(`#btn-run-${recipeName}`).click(); + cy.btnModalOkClick(); }); Cypress.Commands.add("uploadRecipeJson", ({ prefix }, fixturePath) => { cy.fixture(fixturePath).then((data) => { - cy.visit(`${prefix}/Admin/DeploymentPlan/Import/Json`); - cy.get('.CodeMirror').should('be.visible'); - cy.get("body").then($body => { - $body.find(".CodeMirror")[0].CodeMirror.setValue(JSON.stringify(data)); - }); - cy.get('.ta-content > form').submit(); - // make sure the message-success alert is displayed - cy.get('.message-success').should('contain', "Recipe imported"); + cy.visit(`${prefix}/Admin/DeploymentPlan/Import/Json`); + cy.get('.CodeMirror').should('be.visible'); + cy.get("body").then($body => { + $body.find(".CodeMirror")[0].CodeMirror.setValue(JSON.stringify(data)); + }); + cy.get('.ta-content > form').submit(); + // make sure the message-success alert is displayed + cy.get('.message-success').should('contain', "Recipe imported"); }); -}); + }); function byCy(id, exact) { - if (exact) { - return `[data-cy="${id}"]`; - } - return `[data-cy^="${id}"]`; + if (exact) { + return `[data-cy="${id}"]`; + } + return `[data-cy^="${id}"]`; } Cypress.Commands.add('getByCy', (selector, exact = false) => { - return cy.get(byCy(selector, exact)); + return cy.get(byCy(selector, exact)); }); Cypress.Commands.add( - 'findByCy', - { prevSubject: 'optional' }, - (subject, selector, exact = false) => { - return subject - ? cy.wrap(subject).find(byCy(selector, exact)) - : cy.find(byCy(selector, exact)); - }, + 'findByCy', + {prevSubject: 'optional'}, + (subject, selector, exact = false) => { + return subject + ? cy.wrap(subject).find(byCy(selector, exact)) + : cy.find(byCy(selector, exact)); + }, ); -Cypress.Commands.add("setPageSize", ({ prefix = "" }, size) => { - cy.visit(`${prefix}/Admin/Settings/general`); - cy.get('#ISite_PageSize') - .clear() - .type(size); - cy.btnSaveClick(); - // wait until the success message is displayed - cy.get('.message-success'); +Cypress.Commands.add("setPageSize", ({prefix = ""}, size) => { + cy.visit(`${prefix}/Admin/Settings/general`); + cy.get('#ISite_PageSize') + .clear() + .type(size); + cy.btnSaveClick(); + // wait until the success message is displayed + cy.get('.message-success'); }); Cypress.Commands.add("enableFeature", ({ prefix }, featureName) => { - cy.visit(`${prefix}/Admin/Features`); - cy.get(`#btn-enable-${featureName}`).click(); + cy.visit(`${prefix}/Admin/Features`); + cy.get(`#btn-enable-${featureName}`).click(); }); Cypress.Commands.add("diableFeature", ({ prefix }, featureName) => { - cy.visit(`${prefix}/Admin/Features`); - cy.get(`#btn-diable-${featureName}`).click(); + cy.visit(`${prefix}/Admin/Features`); + cy.get(`#btn-diable-${featureName}`).click(); }); Cypress.Commands.add("visitContentPage", ({ prefix }, contentItemId) => { - cy.visit(`${prefix}/Contents/ContentItems/${contentItemId}`); + cy.visit(`${prefix}/Contents/ContentItems/${contentItemId}`); }); -Cypress.Commands.add('btnCreateClick', function () { - cy.get('.btn.create').click(); +Cypress.Commands.add('btnCreateClick', function() { + cy.get('.btn.create').click(); }); -Cypress.Commands.add('btnSaveClick', function () { - cy.get('.btn.save').click(); +Cypress.Commands.add('btnSaveClick', function() { + cy.get('.btn.save').click(); }); -Cypress.Commands.add('btnSaveContinueClick', function () { - cy.get('.dropdown-item.save-continue').click(); +Cypress.Commands.add('btnSaveContinueClick', function() { + cy.get('.dropdown-item.save-continue').click(); }); -Cypress.Commands.add('btnCancelClick', function () { - cy.get('.btn.cancel').click(); +Cypress.Commands.add('btnCancelClick', function() { + cy.get('.btn.cancel').click(); }); -Cypress.Commands.add('btnPublishClick', function () { - cy.get('.btn.public').click(); +Cypress.Commands.add('btnPublishClick', function() { + cy.get('.btn.public').click(); }); -Cypress.Commands.add('btnPublishContinueClick', function () { - cy.get('.dropdown-item.publish-continue').click(); +Cypress.Commands.add('btnPublishContinueClick', function() { + cy.get('.dropdown-item.publish-continue').click(); }); -Cypress.Commands.add('btnModalOkClick', function () { - cy.get("#modalOkButton").click(); +Cypress.Commands.add('btnModalOkClick', function() { + cy.get("#modalOkButton").click(); }); diff --git a/test/OrchardCore.Tests.Functional/cypress-commands/dist/index.mjs b/test/OrchardCore.Tests.Functional/cypress-commands/dist/index.mjs index c250835617b..77e0ceb3cbf 100644 --- a/test/OrchardCore.Tests.Functional/cypress-commands/dist/index.mjs +++ b/test/OrchardCore.Tests.Functional/cypress-commands/dist/index.mjs @@ -1,153 +1,153 @@ -Cypress.Commands.add("login", function ({ prefix = "" } = {}) { - const config = Cypress.config('orchard'); - cy.visit(`${prefix}/login`); - cy.get("#LoginForm_UserName").type(config.username); - cy.get("#LoginForm_Password").type(config.password); - cy.get("#LoginForm_UserName").closest('form').submit(); +Cypress.Commands.add("login", function({ prefix = ""}={}) { + const config = Cypress.config('orchard'); + cy.visit(`${prefix}/login`); + cy.get("#LoginForm_UserName").type(config.username); + cy.get("#LoginForm_Password").type(config.password); + cy.get("#LoginForm_UserName").closest('form').submit(); }); Cypress.Commands.add("visitTenantSetupPage", ({ name }) => { - cy.visit("/Admin/Tenants"); - cy.get(`#btn-setup-${name}`).click(); + cy.visit("/Admin/Tenants"); + cy.get(`#btn-setup-${name}`).click(); }); -Cypress.Commands.add("siteSetup", ({ name, setupRecipe }) => { - const config = Cypress.config('orchard'); - cy.get("#SiteName").type(name); - cy.get("body").then($body => { - const elem = $body.find("#RecipeName"); - if (elem) { - elem.val(setupRecipe); - } - const db = $body.find("#DatabaseProvider"); - if (db.length > 0 && db.val() == "") { - db.val("Sqlite"); - } - }); - cy.get("#UserName").type(config.username); - cy.get("#Email").type(config.email); - cy.get("#Password").type(config.password); - cy.get("#PasswordConfirmation").type(config.password); - cy.get("#SubmitButton").click(); +Cypress.Commands.add("siteSetup", ({ name, setupRecipe }) => { + const config = Cypress.config('orchard'); + cy.get("#SiteName").type(name); + cy.get("body").then($body => { + const elem = $body.find("#RecipeName"); + if (elem) { + elem.val(setupRecipe); + } + const db = $body.find("#DatabaseProvider"); + if(db.length > 0 && db.val() == "") { + db.val("Sqlite"); + } + }); + cy.get("#UserName").type(config.username); + cy.get("#Email").type(config.email); + cy.get("#Password").type(config.password); + cy.get("#PasswordConfirmation").type(config.password); + cy.get("#SubmitButton").click(); }); -Cypress.Commands.add('newTenant', function (tenantInfo) { - cy.login(); - cy.createTenant(tenantInfo); - cy.visitTenantSetupPage(tenantInfo); - cy.siteSetup(tenantInfo); +Cypress.Commands.add('newTenant', function(tenantInfo) { + cy.login(); + cy.createTenant(tenantInfo); + cy.visitTenantSetupPage(tenantInfo); + cy.siteSetup(tenantInfo); }); Cypress.Commands.add("createTenant", ({ name, prefix, setupRecipe, description }) => { - // We create tenants on the SaaS tenant - cy.visit("/Admin/Tenants"); - cy.btnCreateClick(); - cy.get("#Name").type(name, { force: true }); - cy.get("#Description").type(`Recipe: ${setupRecipe}. ${description || ''}`, { force: true }); - cy.get("#RequestUrlPrefix").type(prefix, { force: true }); - cy.get("#RecipeName").select(setupRecipe); - cy.get("body").then($body => { - const db = $body.find("#DatabaseProvider"); - // if a database provider is already specified by an environment variable.. leave it as is - // this assumes that if you set the provider, you also set the connectionString - if (db.length > 0 && db.val() == "") { - db.val('Sqlite'); - } else { - //set the tablePrefix to the name. - const prefix = $body.find("#TablePrefix"); - if (prefix.length > 0) { - prefix.val(name); - } + // We create tenants on the SaaS tenant + cy.visit("/Admin/Tenants"); + cy.btnCreateClick(); + cy.get("#Name").type(name, {force:true}); + cy.get("#Description").type(`Recipe: ${setupRecipe}. ${description || ''}`, {force:true}); + cy.get("#RequestUrlPrefix").type(prefix, {force:true}); + cy.get("#RecipeName").select(setupRecipe); + cy.get("body").then($body => { + const db = $body.find("#DatabaseProvider"); + // if a database provider is already specified by an environment variable.. leave it as is + // this assumes that if you set the provider, you also set the connectionString + if (db.length > 0 && db.val() == "") { + db.val('Sqlite'); + } else { + //set the tablePrefix to the name. + const prefix = $body.find("#TablePrefix"); + if(prefix.length > 0){ + prefix.val(name); } - }); - cy.btnCreateClick(); + } + }); + cy.btnCreateClick(); }); Cypress.Commands.add("runRecipe", ({ prefix }, recipeName) => { - cy.visit(`${prefix}/Admin/Recipes`); - cy.get(`#btn-run-${recipeName}`).click(); - cy.btnModalOkClick(); + cy.visit(`${prefix}/Admin/Recipes`); + cy.get(`#btn-run-${recipeName}`).click(); + cy.btnModalOkClick(); }); Cypress.Commands.add("uploadRecipeJson", ({ prefix }, fixturePath) => { cy.fixture(fixturePath).then((data) => { - cy.visit(`${prefix}/Admin/DeploymentPlan/Import/Json`); - cy.get('.CodeMirror').should('be.visible'); - cy.get("body").then($body => { - $body.find(".CodeMirror")[0].CodeMirror.setValue(JSON.stringify(data)); - }); - cy.get('.ta-content > form').submit(); - // make sure the message-success alert is displayed - cy.get('.message-success').should('contain', "Recipe imported"); + cy.visit(`${prefix}/Admin/DeploymentPlan/Import/Json`); + cy.get('.CodeMirror').should('be.visible'); + cy.get("body").then($body => { + $body.find(".CodeMirror")[0].CodeMirror.setValue(JSON.stringify(data)); + }); + cy.get('.ta-content > form').submit(); + // make sure the message-success alert is displayed + cy.get('.message-success').should('contain', "Recipe imported"); }); -}); + }); function byCy(id, exact) { - if (exact) { - return `[data-cy="${id}"]`; - } - return `[data-cy^="${id}"]`; + if (exact) { + return `[data-cy="${id}"]`; + } + return `[data-cy^="${id}"]`; } Cypress.Commands.add('getByCy', (selector, exact = false) => { - return cy.get(byCy(selector, exact)); + return cy.get(byCy(selector, exact)); }); Cypress.Commands.add( - 'findByCy', - { prevSubject: 'optional' }, - (subject, selector, exact = false) => { - return subject - ? cy.wrap(subject).find(byCy(selector, exact)) - : cy.find(byCy(selector, exact)); - }, + 'findByCy', + {prevSubject: 'optional'}, + (subject, selector, exact = false) => { + return subject + ? cy.wrap(subject).find(byCy(selector, exact)) + : cy.find(byCy(selector, exact)); + }, ); -Cypress.Commands.add("setPageSize", ({ prefix = "" }, size) => { - cy.visit(`${prefix}/Admin/Settings/general`); - cy.get('#ISite_PageSize') - .clear() - .type(size); - cy.btnSaveClick(); - // wait until the success message is displayed - cy.get('.message-success'); +Cypress.Commands.add("setPageSize", ({prefix = ""}, size) => { + cy.visit(`${prefix}/Admin/Settings/general`); + cy.get('#ISite_PageSize') + .clear() + .type(size); + cy.btnSaveClick(); + // wait until the success message is displayed + cy.get('.message-success'); }); Cypress.Commands.add("enableFeature", ({ prefix }, featureName) => { - cy.visit(`${prefix}/Admin/Features`); - cy.get(`#btn-enable-${featureName}`).click(); + cy.visit(`${prefix}/Admin/Features`); + cy.get(`#btn-enable-${featureName}`).click(); }); Cypress.Commands.add("diableFeature", ({ prefix }, featureName) => { - cy.visit(`${prefix}/Admin/Features`); - cy.get(`#btn-diable-${featureName}`).click(); + cy.visit(`${prefix}/Admin/Features`); + cy.get(`#btn-diable-${featureName}`).click(); }); Cypress.Commands.add("visitContentPage", ({ prefix }, contentItemId) => { - cy.visit(`${prefix}/Contents/ContentItems/${contentItemId}`); + cy.visit(`${prefix}/Contents/ContentItems/${contentItemId}`); }); -Cypress.Commands.add('btnCreateClick', function () { - cy.get('.btn.create').click(); +Cypress.Commands.add('btnCreateClick', function() { + cy.get('.btn.create').click(); }); -Cypress.Commands.add('btnSaveClick', function () { - cy.get('.btn.save').click(); +Cypress.Commands.add('btnSaveClick', function() { + cy.get('.btn.save').click(); }); -Cypress.Commands.add('btnSaveContinueClick', function () { - cy.get('.dropdown-item.save-continue').click(); +Cypress.Commands.add('btnSaveContinueClick', function() { + cy.get('.dropdown-item.save-continue').click(); }); -Cypress.Commands.add('btnCancelClick', function () { - cy.get('.btn.cancel').click(); +Cypress.Commands.add('btnCancelClick', function() { + cy.get('.btn.cancel').click(); }); -Cypress.Commands.add('btnPublishClick', function () { - cy.get('.btn.public').click(); +Cypress.Commands.add('btnPublishClick', function() { + cy.get('.btn.public').click(); }); -Cypress.Commands.add('btnPublishContinueClick', function () { - cy.get('.dropdown-item.publish-continue').click(); +Cypress.Commands.add('btnPublishContinueClick', function() { + cy.get('.dropdown-item.publish-continue').click(); }); -Cypress.Commands.add('btnModalOkClick', function () { - cy.get("#modalOkButton").click(); +Cypress.Commands.add('btnModalOkClick', function() { + cy.get("#modalOkButton").click(); }); diff --git a/test/OrchardCore.Tests.Functional/cypress-commands/dist/test-runner.js b/test/OrchardCore.Tests.Functional/cypress-commands/dist/test-runner.js index 3900795a6e2..8e5bd7c1588 100644 --- a/test/OrchardCore.Tests.Functional/cypress-commands/dist/test-runner.js +++ b/test/OrchardCore.Tests.Functional/cypress-commands/dist/test-runner.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - // This module was originally build by the OrchardCore team const child_process = require("child_process"); const fs = require("fs-extra"); @@ -10,6 +8,14 @@ const path = require("path"); global.log = function (msg) { let now = new Date().toLocaleTimeString(); console.log(`[${now}] ${msg}\n`); + + if (msg.indexOf("Exception") >= 0) { + throw new Error("An exception was detected"); + } + + if (msg.indexOf("fail:") == 0) { + throw new Error("An error was logged"); + } }; // Build the dotnet application in release mode diff --git a/test/OrchardCore.Tests.Functional/cypress-commands/dist/test-runner.mjs b/test/OrchardCore.Tests.Functional/cypress-commands/dist/test-runner.mjs index 48b9bb7c717..3e757ef0dab 100644 --- a/test/OrchardCore.Tests.Functional/cypress-commands/dist/test-runner.mjs +++ b/test/OrchardCore.Tests.Functional/cypress-commands/dist/test-runner.mjs @@ -6,12 +6,20 @@ const path = require("path"); global.log = function (msg) { let now = new Date().toLocaleTimeString(); console.log(`[${now}] ${msg}\n`); + + if (msg.indexOf("Exception") >= 0) { + throw new Error("An exception was detected"); + } + + if (msg.indexOf("fail:") == 0) { + throw new Error("An error was logged"); + } }; // Build the dotnet application in release mode -function build(dir) { +function build(dir, dotnetVersion) { global.log("Building ..."); - child_process.spawnSync("dotnet", ["build", "-c", "Release"], { cwd: dir }); + child_process.spawnSync("dotnet", ["build", "-c", "Release", "-f", dotnetVersion], { cwd: dir }); } // destructive action that deletes the App_Data folder @@ -20,12 +28,29 @@ function deleteDirectory(dir) { global.log(`${dir} deleted`); } +// Copy the migrations recipe. +function copyMigrationsRecipeFile(dir) { + + const recipeFilePath = 'Recipes/migrations.recipe.json'; + + if (!fs.existsSync(`./${recipeFilePath}`) || fs.existsSync(`${dir}/${recipeFilePath}`)) { + return; + } + + if (!fs.existsSync(`${dir}/Recipes`)) { + fs.mkdirSync(`${dir}/Recipes`); + } + + fs.copyFile(`./${recipeFilePath}`, `${dir}/${recipeFilePath}`); + global.log(`migrations recipe copied to ${dir}/Recipes`); +} + // Host the dotnet application, does not rebuild function host(dir, assembly, { appDataLocation = './App_Data', dotnetVersion = 'net8.0' } = {}) { if (fs.existsSync(path.join(dir, `bin/Release/${dotnetVersion}/`, assembly))) { global.log("Application already built, skipping build"); } else { - build(dir); + build(dir, dotnetVersion); } global.log("Starting application ..."); @@ -54,6 +79,7 @@ function host(dir, assembly, { appDataLocation = './App_Data', dotnetVersion = ' // combines the functions above, useful when triggering tests from CI function e2e(dir, assembly, { dotnetVersion = 'net8.0' } = {}) { + copyMigrationsRecipeFile(dir); deleteDirectory(path.join(dir, "App_Data_Tests")); var server = host(dir, assembly, { appDataLocation: "./App_Data_Tests", dotnetVersion }); diff --git a/test/OrchardCore.Tests.Functional/cypress-commands/dist/utils.js b/test/OrchardCore.Tests.Functional/cypress-commands/dist/utils.js index 09bdc92355e..7be65a96bbb 100644 --- a/test/OrchardCore.Tests.Functional/cypress-commands/dist/utils.js +++ b/test/OrchardCore.Tests.Functional/cypress-commands/dist/utils.js @@ -1,7 +1,5 @@ 'use strict'; -Object.defineProperty(exports, '__esModule', { value: true }); - // https://stackoverflow.com/questions/105034/how-to-create-guid-uuid function generateUniqueName() { diff --git a/test/OrchardCore.Tests.Functional/cypress-commands/package.json b/test/OrchardCore.Tests.Functional/cypress-commands/package.json index 9e385fbdf3f..d0c0a9144f4 100644 --- a/test/OrchardCore.Tests.Functional/cypress-commands/package.json +++ b/test/OrchardCore.Tests.Functional/cypress-commands/package.json @@ -22,7 +22,7 @@ "testing" ], "scripts": { - "build": "rollup -c", + "build": "rollup -c --bundleConfigAsCjs", "watch": "rollup -c -w" }, "dependencies": { diff --git a/test/OrchardCore.Tests.Functional/cypress-commands/src/tenants.js b/test/OrchardCore.Tests.Functional/cypress-commands/src/tenants.js index e5b412573cb..11bc7a87349 100644 --- a/test/OrchardCore.Tests.Functional/cypress-commands/src/tenants.js +++ b/test/OrchardCore.Tests.Functional/cypress-commands/src/tenants.js @@ -1,9 +1,9 @@ Cypress.Commands.add("login", function({ prefix = ""}={}) { const config = Cypress.config('orchard'); cy.visit(`${prefix}/login`); - cy.get("#UserName").type(config.username); - cy.get("#Password").type(config.password); - cy.get("#UserName").closest('form').submit(); + cy.get("#LoginForm_UserName").type(config.username); + cy.get("#LoginForm_Password").type(config.password); + cy.get("#LoginForm_UserName").closest('form').submit(); }); Cypress.Commands.add("visitTenantSetupPage", ({ name }) => { diff --git a/test/OrchardCore.Tests.Functional/cypress-commands/src/test-runner.js b/test/OrchardCore.Tests.Functional/cypress-commands/src/test-runner.js index 13cdc13b65a..d37a6b09fee 100644 --- a/test/OrchardCore.Tests.Functional/cypress-commands/src/test-runner.js +++ b/test/OrchardCore.Tests.Functional/cypress-commands/src/test-runner.js @@ -6,6 +6,14 @@ const path = require("path"); global.log = function (msg) { let now = new Date().toLocaleTimeString(); console.log(`[${now}] ${msg}\n`); + + if (msg.indexOf("Exception") >= 0) { + throw new Error("An exception was detected"); + } + + if (msg.indexOf("fail:") == 0) { + throw new Error("An error was logged"); + } }; // Build the dotnet application in release mode @@ -20,6 +28,23 @@ export function deleteDirectory(dir) { global.log(`${dir} deleted`); } +// Copy the migrations recipe. +function copyMigrationsRecipeFile(dir) { + + const recipeFilePath = 'Recipes/migrations.recipe.json'; + + if (!fs.existsSync(`./${recipeFilePath}`) || fs.existsSync(`${dir}/${recipeFilePath}`)) { + return; + } + + if (!fs.existsSync(`${dir}/Recipes`)) { + fs.mkdirSync(`${dir}/Recipes`); + } + + fs.copyFile(`./${recipeFilePath}`, `${dir}/${recipeFilePath}`); + global.log(`migrations recipe copied to ${dir}/Recipes`); +} + // Host the dotnet application, does not rebuild export function host(dir, assembly, { appDataLocation = './App_Data', dotnetVersion = 'net8.0' } = {}) { if (fs.existsSync(path.join(dir, `bin/Release/${dotnetVersion}/`, assembly))) { @@ -54,6 +79,7 @@ export function host(dir, assembly, { appDataLocation = './App_Data', dotnetVers // combines the functions above, useful when triggering tests from CI export function e2e(dir, assembly, { dotnetVersion = 'net8.0' } = {}) { + copyMigrationsRecipeFile(dir); deleteDirectory(path.join(dir, "App_Data_Tests")); var server = host(dir, assembly, { appDataLocation: "./App_Data_Tests", dotnetVersion }); From d76f60a6141db67f9e28849413d9304bd3ecf58b Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Tue, 12 Nov 2024 09:49:48 -0800 Subject: [PATCH 10/63] Undo binary breaking change (#16996) --- ...tensions.cs => SiteServiceCollectionExtensions.cs} | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) rename src/OrchardCore/OrchardCore.DisplayManagement/{ServiceCollectionExtensions.cs => SiteServiceCollectionExtensions.cs} (55%) diff --git a/src/OrchardCore/OrchardCore.DisplayManagement/ServiceCollectionExtensions.cs b/src/OrchardCore/OrchardCore.DisplayManagement/SiteServiceCollectionExtensions.cs similarity index 55% rename from src/OrchardCore/OrchardCore.DisplayManagement/ServiceCollectionExtensions.cs rename to src/OrchardCore/OrchardCore.DisplayManagement/SiteServiceCollectionExtensions.cs index c72dfd53e47..d7e65048046 100644 --- a/src/OrchardCore/OrchardCore.DisplayManagement/ServiceCollectionExtensions.cs +++ b/src/OrchardCore/OrchardCore.DisplayManagement/SiteServiceCollectionExtensions.cs @@ -3,13 +3,16 @@ namespace OrchardCore.DisplayManagement.Handlers; -public static class ServiceCollectionExtensions +/// +/// Rename this file to ServiceCollectionExtensions in v3.0. +/// +public static class SiteServiceCollectionExtensions { public static IServiceCollection AddSiteDisplayDriver(this IServiceCollection services) where TDriver : class, IDisplayDriver - => services.AddDisplayDriver(); + => services.AddDisplayDriver(); public static IServiceCollection AddDisplayDriver(this IServiceCollection services) - where TDriver : class, IDisplayDriver - => services.AddScoped, TDriver>(); + where TDriver : class, IDisplayDriver + => services.AddScoped, TDriver>(); } From dd93748720d00f4886247c50e76344f01f959a69 Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Tue, 12 Nov 2024 09:59:39 -0800 Subject: [PATCH 11/63] Fix SelectContentTypes usage in Azure AI (#16994) --- .../ViewComponents/SelectContentTypesViewComponent.cs | 6 ++---- .../OrchardCore.Search.AzureAI/Views/Admin/Create.cshtml | 2 +- .../Views/Admin/Edit.cshtml | 9 +-------- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/ViewComponents/SelectContentTypesViewComponent.cs b/src/OrchardCore.Modules/OrchardCore.Contents/ViewComponents/SelectContentTypesViewComponent.cs index cdcd8734374..d9a2ecb15bc 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/ViewComponents/SelectContentTypesViewComponent.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/ViewComponents/SelectContentTypesViewComponent.cs @@ -16,14 +16,12 @@ public SelectContentTypesViewComponent(IContentDefinitionManager contentDefiniti public async Task InvokeAsync(IEnumerable selectedContentTypes, string htmlName, string stereotype) { - selectedContentTypes ??= Array.Empty(); - - var contentTypes = await ContentTypeSelection.BuildAsync(_contentDefinitionManager, selectedContentTypes); + var contentTypes = await ContentTypeSelection.BuildAsync(_contentDefinitionManager, selectedContentTypes ?? []); if (!string.IsNullOrEmpty(stereotype)) { contentTypes = contentTypes - .Where(x => x.ContentTypeDefinition.GetStereotype() == stereotype) + .Where(x => x.ContentTypeDefinition.StereotypeEquals(stereotype)) .ToArray(); } diff --git a/src/OrchardCore.Modules/OrchardCore.Search.AzureAI/Views/Admin/Create.cshtml b/src/OrchardCore.Modules/OrchardCore.Search.AzureAI/Views/Admin/Create.cshtml index ca532023c43..66ec45d1f8e 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.AzureAI/Views/Admin/Create.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Search.AzureAI/Views/Admin/Create.cshtml @@ -31,7 +31,7 @@ @T["The content types to index. Choose at least one."] - @await Component.InvokeAsync("SelectContentTypes", new { htmlName = Html.NameFor(m => m.IndexedContentTypes) }) + @await Component.InvokeAsync("SelectContentTypes", new { selectedContentTypes = Model.IndexedContentTypes, htmlName = Html.NameFor(m => m.IndexedContentTypes) }) diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Views/Admin/Edit.cshtml b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Views/Admin/Edit.cshtml index 90bae6d65f3..27d54356951 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Views/Admin/Edit.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Views/Admin/Edit.cshtml @@ -37,14 +37,7 @@ else
@T["The content types to index. Choose at least one."] - @if (Model.IsCreate) - { - @await Component.InvokeAsync("SelectContentTypes", new { htmlName = Html.NameFor(m => m.IndexedContentTypes) }) - } - else - { - @await Component.InvokeAsync("SelectContentTypes", new { selectedContentTypes = Model.IndexedContentTypes, htmlName = Html.NameFor(m => m.IndexedContentTypes) }) - } + @await Component.InvokeAsync("SelectContentTypes", new { selectedContentTypes = Model.IndexedContentTypes, htmlName = Html.NameFor(m => m.IndexedContentTypes) })
From 526a162887e91b6a47929ff44fece8dd7ba3443c Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Tue, 12 Nov 2024 11:59:42 -0800 Subject: [PATCH 12/63] Prevent NullReferenceException in ElasticSearch (#16999) --- .../Services/ElasticIndexManager.cs | 51 ++++++++++--------- .../Services/ElasticSearchQueryService.cs | 12 +++-- 2 files changed, 37 insertions(+), 26 deletions(-) diff --git a/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Services/ElasticIndexManager.cs b/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Services/ElasticIndexManager.cs index 09c7177177a..75c2a9877be 100644 --- a/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Services/ElasticIndexManager.cs +++ b/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Services/ElasticIndexManager.cs @@ -6,6 +6,7 @@ using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Nest; +using OrchardCore.ContentManagement; using OrchardCore.Contents.Indexing; using OrchardCore.Environment.Shell; using OrchardCore.Indexing; @@ -26,7 +27,7 @@ public sealed class ElasticIndexManager private readonly ShellSettings _shellSettings; private readonly IClock _clock; private readonly ILogger _logger; - private readonly ElasticsearchOptions _elasticsearchOptions; + private readonly ElasticsearchOptions _elasticSearchOptions; private readonly ConcurrentDictionary _timestamps = new(StringComparer.OrdinalIgnoreCase); private readonly string _lastTaskId = "last_task_id"; private readonly Dictionary> _analyzerGetter = new(StringComparer.OrdinalIgnoreCase) @@ -409,7 +410,7 @@ ILogger logger _shellSettings = shellSettings; _clock = clock; _logger = logger; - _elasticsearchOptions = elasticsearchOptions.Value; + _elasticSearchOptions = elasticsearchOptions.Value; } /// @@ -438,11 +439,11 @@ public async Task CreateIndexAsync(ElasticIndexSettings elasticIndexSettin ? null : elasticIndexSettings.AnalyzerName) ?? ElasticsearchConstants.DefaultAnalyzer; - if (_elasticsearchOptions.Analyzers.TryGetValue(analyzerName, out var analyzerProperties)) + if (_elasticSearchOptions.Analyzers.TryGetValue(analyzerName, out var analyzerProperties)) { - if (_elasticsearchOptions.Filter is not null) + if (_elasticSearchOptions.Filter is not null) { - var tokenFiltersDescriptor = GetTokenFilterDescriptor(_elasticsearchOptions.Filter); + var tokenFiltersDescriptor = GetTokenFilterDescriptor(_elasticSearchOptions.Filter); analysisDescriptor.TokenFilters(f => tokenFiltersDescriptor); } @@ -914,7 +915,13 @@ public async Task StoreDocumentsAsync(string indexName, IEnumerable. public async Task SearchAsync(string indexName, QueryContainer query, List sort, int from, int size) { - var elasticTopDocs = new ElasticTopDocs(); + ArgumentException.ThrowIfNullOrEmpty(indexName); + ArgumentNullException.ThrowIfNull(query); + + var elasticTopDocs = new ElasticTopDocs() + { + TopDocs = [], + }; if (await ExistsAsync(indexName)) { @@ -925,7 +932,7 @@ public async Task SearchAsync(string indexName, QueryContainer q Query = query, From = from, Size = size, - Sort = sort + Sort = sort ?? [], }; var searchResponse = await _elasticClient.SearchAsync>(searchRequest); @@ -934,8 +941,6 @@ public async Task SearchAsync(string indexName, QueryContainer q { elasticTopDocs.Count = searchResponse.Hits.Count; - var topDocs = new List>(); - var documents = searchResponse.Documents.GetEnumerator(); var hits = searchResponse.Hits.GetEnumerator(); @@ -945,7 +950,7 @@ public async Task SearchAsync(string indexName, QueryContainer q if (document != null) { - topDocs.Add(document); + elasticTopDocs.TopDocs.Add(document); continue; } @@ -954,13 +959,11 @@ public async Task SearchAsync(string indexName, QueryContainer q var topDoc = new Dictionary { - { "ContentItemId", hit.Id } + { nameof(ContentItem.ContentItemId), hit.Id }, }; - topDocs.Add(topDoc); + elasticTopDocs.TopDocs.Add(topDoc); } - - elasticTopDocs.TopDocs = topDocs; } _timestamps[fullIndexName] = _clock.UtcNow; @@ -974,6 +977,8 @@ public async Task SearchAsync(string indexName, QueryContainer q /// public async Task SearchAsync(string indexName, Func elasticClient) { + ArgumentException.ThrowIfNullOrEmpty(indexName); + if (await ExistsAsync(indexName)) { await elasticClient(_elasticClient); @@ -994,14 +999,14 @@ private static Dictionary CreateElasticDocument(DocumentIndex do { switch (entry.Type) { - case DocumentIndex.Types.Boolean: + case DocumentIndexBase.Types.Boolean: if (entry.Value is bool boolValue) { AddValue(entries, entry.Name, boolValue); } break; - case DocumentIndex.Types.DateTime: + case DocumentIndexBase.Types.DateTime: if (entry.Value is DateTimeOffset offsetValue) { @@ -1014,7 +1019,7 @@ private static Dictionary CreateElasticDocument(DocumentIndex do break; - case DocumentIndex.Types.Integer: + case DocumentIndexBase.Types.Integer: if (entry.Value != null && long.TryParse(entry.Value.ToString(), out var value)) { AddValue(entries, entry.Name, value); @@ -1022,14 +1027,14 @@ private static Dictionary CreateElasticDocument(DocumentIndex do break; - case DocumentIndex.Types.Number: + case DocumentIndexBase.Types.Number: if (entry.Value != null) { AddValue(entries, entry.Name, Convert.ToDouble(entry.Value)); } break; - case DocumentIndex.Types.Text: + case DocumentIndexBase.Types.Text: if (entry.Value != null) { var stringValue = Convert.ToString(entry.Value); @@ -1040,8 +1045,8 @@ private static Dictionary CreateElasticDocument(DocumentIndex do } } break; - case DocumentIndex.Types.GeoPoint: - if (entry.Value is DocumentIndex.GeoPoint point) + case DocumentIndexBase.Types.GeoPoint: + if (entry.Value is DocumentIndexBase.GeoPoint point) { AddValue(entries, entry.Name, new GeoLocation((double)point.Latitude, (double)point.Longitude)); } @@ -1093,9 +1098,9 @@ private string GetIndexPrefix() { var parts = new List(); - if (!string.IsNullOrWhiteSpace(_elasticsearchOptions.IndexPrefix)) + if (!string.IsNullOrWhiteSpace(_elasticSearchOptions.IndexPrefix)) { - parts.Add(_elasticsearchOptions.IndexPrefix.ToLowerInvariant()); + parts.Add(_elasticSearchOptions.IndexPrefix.ToLowerInvariant()); } parts.Add(_shellSettings.Name.ToLowerInvariant()); diff --git a/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Services/ElasticSearchQueryService.cs b/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Services/ElasticSearchQueryService.cs index 3ea42864997..795715ac39b 100644 --- a/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Services/ElasticSearchQueryService.cs +++ b/src/OrchardCore/OrchardCore.Search.Elasticsearch.Core/Services/ElasticSearchQueryService.cs @@ -1,4 +1,5 @@ using Nest; +using OrchardCore.ContentManagement; namespace OrchardCore.Search.Elasticsearch.Core.Services; @@ -13,13 +14,18 @@ public ElasticSearchQueryService(ElasticIndexManager elasticIndexManager) public async Task> ExecuteQueryAsync(string indexName, QueryContainer query, List sort, int from, int size) { - var contentItemIds = new List(); - var results = await _elasticIndexManager.SearchAsync(indexName, query, sort, from, size); + if (results?.TopDocs is null || results.TopDocs.Count == 0) + { + return []; + } + + var contentItemIds = new List(); + foreach (var item in results.TopDocs) { - contentItemIds.Add(item.GetValueOrDefault("ContentItemId").ToString()); + contentItemIds.Add(item.GetValueOrDefault(nameof(ContentItem.ContentItemId)).ToString()); } return contentItemIds; From 80a45271e7170b9bbf594b8b25d208eb108d6f01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Ros?= Date: Tue, 12 Nov 2024 13:10:53 -0800 Subject: [PATCH 13/63] Remove unnecessary usings (#17000) --- src/OrchardCore.Modules/OrchardCore.ContentPreview/Startup.cs | 1 - src/OrchardCore.Modules/OrchardCore.Cors/Startup.cs | 1 - src/OrchardCore.Modules/OrchardCore.Diagnostics/Startup.cs | 1 - src/OrchardCore.Modules/OrchardCore.Facebook/StartupLogin.cs | 1 - src/OrchardCore.Modules/OrchardCore.GitHub/Startup.cs | 1 - .../OrchardCore.Google/GoogleAuthenticationStartup.cs | 1 - .../MicrosoftAccountStartup.cs | 1 - src/OrchardCore.Modules/OrchardCore.ReverseProxy/Startup.cs | 1 - src/OrchardCore.Modules/OrchardCore.Twitter/Startup.cs | 1 - .../OrchardCoreBuilderExtensions.cs | 1 - .../Documents/OrchardCoreBuilderExtensions.cs | 1 - .../RazorPages/ModularPageMvcCoreBuilderExtensions.cs | 1 - 12 files changed, 12 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.ContentPreview/Startup.cs b/src/OrchardCore.Modules/OrchardCore.ContentPreview/Startup.cs index 1f53c634d1d..8be29a24323 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentPreview/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.ContentPreview/Startup.cs @@ -1,6 +1,5 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using OrchardCore.ContentManagement; using OrchardCore.ContentManagement.Display.ContentDisplay; diff --git a/src/OrchardCore.Modules/OrchardCore.Cors/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Cors/Startup.cs index 3bf19aa4b78..dcb4187d270 100644 --- a/src/OrchardCore.Modules/OrchardCore.Cors/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Cors/Startup.cs @@ -2,7 +2,6 @@ using Microsoft.AspNetCore.Cors.Infrastructure; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using OrchardCore.Cors.Services; using OrchardCore.Modules; diff --git a/src/OrchardCore.Modules/OrchardCore.Diagnostics/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Diagnostics/Startup.cs index dd3937239bf..8cc37272137 100644 --- a/src/OrchardCore.Modules/OrchardCore.Diagnostics/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Diagnostics/Startup.cs @@ -2,7 +2,6 @@ using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; namespace OrchardCore.Diagnostics; diff --git a/src/OrchardCore.Modules/OrchardCore.Facebook/StartupLogin.cs b/src/OrchardCore.Modules/OrchardCore.Facebook/StartupLogin.cs index 7fc9c65f7dc..16a6c24c926 100644 --- a/src/OrchardCore.Modules/OrchardCore.Facebook/StartupLogin.cs +++ b/src/OrchardCore.Modules/OrchardCore.Facebook/StartupLogin.cs @@ -1,7 +1,6 @@ using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Facebook; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Handlers; diff --git a/src/OrchardCore.Modules/OrchardCore.GitHub/Startup.cs b/src/OrchardCore.Modules/OrchardCore.GitHub/Startup.cs index 6a03ca8eeec..dff459faeba 100644 --- a/src/OrchardCore.Modules/OrchardCore.GitHub/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.GitHub/Startup.cs @@ -1,6 +1,5 @@ using Microsoft.AspNetCore.Authentication; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.GitHub.Configuration; diff --git a/src/OrchardCore.Modules/OrchardCore.Google/GoogleAuthenticationStartup.cs b/src/OrchardCore.Modules/OrchardCore.Google/GoogleAuthenticationStartup.cs index fca58de98b8..13b6c07e580 100644 --- a/src/OrchardCore.Modules/OrchardCore.Google/GoogleAuthenticationStartup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Google/GoogleAuthenticationStartup.cs @@ -2,7 +2,6 @@ using Microsoft.AspNetCore.Authentication.Google; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Google.Analytics; diff --git a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/MicrosoftAccountStartup.cs b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/MicrosoftAccountStartup.cs index cdd1496ce80..9270d9ca2b9 100644 --- a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/MicrosoftAccountStartup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/MicrosoftAccountStartup.cs @@ -1,7 +1,6 @@ using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.MicrosoftAccount; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using OrchardCore.Deployment; using OrchardCore.DisplayManagement.Handlers; diff --git a/src/OrchardCore.Modules/OrchardCore.ReverseProxy/Startup.cs b/src/OrchardCore.Modules/OrchardCore.ReverseProxy/Startup.cs index 3d89f4b82bc..fd6097be57a 100644 --- a/src/OrchardCore.Modules/OrchardCore.ReverseProxy/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.ReverseProxy/Startup.cs @@ -1,7 +1,6 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using OrchardCore.DisplayManagement.Handlers; using OrchardCore.Modules; diff --git a/src/OrchardCore.Modules/OrchardCore.Twitter/Startup.cs b/src/OrchardCore.Modules/OrchardCore.Twitter/Startup.cs index 0b5206d661a..1b4d4664f03 100644 --- a/src/OrchardCore.Modules/OrchardCore.Twitter/Startup.cs +++ b/src/OrchardCore.Modules/OrchardCore.Twitter/Startup.cs @@ -1,7 +1,6 @@ using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.Twitter; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Http.Resilience; using Microsoft.Extensions.Options; using OrchardCore.DisplayManagement.Handlers; diff --git a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/OrchardCoreBuilderExtensions.cs b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/OrchardCoreBuilderExtensions.cs index 7192550d572..86729844c30 100644 --- a/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/OrchardCoreBuilderExtensions.cs +++ b/src/OrchardCore/OrchardCore.DisplayManagement.Liquid/OrchardCoreBuilderExtensions.cs @@ -1,7 +1,6 @@ using Fluid; using Microsoft.AspNetCore.Mvc.ApplicationParts; using Microsoft.AspNetCore.Mvc.Razor.Compilation; -using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using OrchardCore.DisplayManagement.Descriptors.ShapeTemplateStrategy; using OrchardCore.DisplayManagement.Liquid; diff --git a/src/OrchardCore/OrchardCore.Infrastructure/Documents/OrchardCoreBuilderExtensions.cs b/src/OrchardCore/OrchardCore.Infrastructure/Documents/OrchardCoreBuilderExtensions.cs index af3089aabee..ed61b8b9178 100644 --- a/src/OrchardCore/OrchardCore.Infrastructure/Documents/OrchardCoreBuilderExtensions.cs +++ b/src/OrchardCore/OrchardCore.Infrastructure/Documents/OrchardCoreBuilderExtensions.cs @@ -1,4 +1,3 @@ -using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; using OrchardCore.Data.Documents; using OrchardCore.Documents; diff --git a/src/OrchardCore/OrchardCore.Mvc.Core/RazorPages/ModularPageMvcCoreBuilderExtensions.cs b/src/OrchardCore/OrchardCore.Mvc.Core/RazorPages/ModularPageMvcCoreBuilderExtensions.cs index 017335e1373..aafba257dd2 100644 --- a/src/OrchardCore/OrchardCore.Mvc.Core/RazorPages/ModularPageMvcCoreBuilderExtensions.cs +++ b/src/OrchardCore/OrchardCore.Mvc.Core/RazorPages/ModularPageMvcCoreBuilderExtensions.cs @@ -2,7 +2,6 @@ using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.DependencyInjection.Extensions; using Microsoft.Extensions.Options; namespace OrchardCore.Mvc.RazorPages; From f3316574aecdbfdad58d25f1783e6e82ddc424e1 Mon Sep 17 00:00:00 2001 From: Hisham Bin Ateya Date: Wed, 13 Nov 2024 01:15:01 +0300 Subject: [PATCH 14/63] Remove unnecessary comment from _ViewImports.cshtml (#17002) --- .../OrchardCore.Alias/Views/_ViewImports.cshtml | 5 ----- .../OrchardCore.Autoroute/Views/_ViewImports.cshtml | 5 ----- .../OrchardCore.ContentFields/Views/_ViewImports.cshtml | 5 ----- .../OrchardCore.ContentPreview/Views/_ViewImports.cshtml | 4 ---- .../OrchardCore.ContentTypes/Views/_ViewImports.cshtml | 5 ----- .../OrchardCore.Contents/Views/_ViewImports.cshtml | 4 ---- .../OrchardCore.CustomSettings/Views/_ViewImports.cshtml | 5 ----- .../OrchardCore.Google/Views/_ViewImports.cshtml | 4 ---- .../Views/_ViewImports.cshtml | 4 ---- .../OrchardCore.OpenId/Views/_ViewImports.cshtml | 4 ---- .../OrchardCore.ReverseProxy/Views/_ViewImports.cshtml | 4 ---- .../Views/_ViewImports.cshtml | 4 ---- .../OrchardCore.Search.Lucene/Views/_ViewImports.cshtml | 4 ---- .../OrchardCore.Search/Views/_ViewImports.cshtml | 4 ---- .../OrchardCore.Settings/Views/_ViewImports.cshtml | 4 ---- .../OrchardCore.Sitemaps/Views/_ViewImports.cshtml | 4 ---- .../OrchardCore.Spatial/Views/_ViewImports.cshtml | 4 ---- .../OrchardCore.Themes/Views/_ViewImports.cshtml | 4 ---- .../OrchardCore.Title/Views/_ViewImports.cshtml | 4 ---- .../OrchardCore.Twitter/Views/_ViewImports.cshtml | 4 ---- .../OrchardCore.Users/Views/_ViewImports.cshtml | 4 ---- .../OrchardCore.Widgets/Views/_ViewImports.cshtml | 4 ---- .../Views/_ViewImports.cshtml | 4 ---- 23 files changed, 97 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Alias/Views/_ViewImports.cshtml b/src/OrchardCore.Modules/OrchardCore.Alias/Views/_ViewImports.cshtml index 78907318446..207b004c8a2 100644 --- a/src/OrchardCore.Modules/OrchardCore.Alias/Views/_ViewImports.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Alias/Views/_ViewImports.cshtml @@ -1,8 +1,3 @@ -@* - For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 - -*@ - @inherits OrchardCore.DisplayManagement.Razor.RazorPage @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @addTagHelper *, OrchardCore.DisplayManagement diff --git a/src/OrchardCore.Modules/OrchardCore.Autoroute/Views/_ViewImports.cshtml b/src/OrchardCore.Modules/OrchardCore.Autoroute/Views/_ViewImports.cshtml index 97a6bac3693..0b6203b7fb0 100644 --- a/src/OrchardCore.Modules/OrchardCore.Autoroute/Views/_ViewImports.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Autoroute/Views/_ViewImports.cshtml @@ -1,8 +1,3 @@ -@* - For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 - -*@ - @inherits OrchardCore.DisplayManagement.Razor.RazorPage @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @addTagHelper *, OrchardCore.Contents.TagHelpers diff --git a/src/OrchardCore.Modules/OrchardCore.ContentFields/Views/_ViewImports.cshtml b/src/OrchardCore.Modules/OrchardCore.ContentFields/Views/_ViewImports.cshtml index 1f73c11b862..30e44390c96 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentFields/Views/_ViewImports.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.ContentFields/Views/_ViewImports.cshtml @@ -1,8 +1,3 @@ -@* - For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 - -*@ - @inherits OrchardCore.DisplayManagement.Razor.RazorPage @using OrchardCore.ContentFields.Settings @using OrchardCore.ContentLocalization diff --git a/src/OrchardCore.Modules/OrchardCore.ContentPreview/Views/_ViewImports.cshtml b/src/OrchardCore.Modules/OrchardCore.ContentPreview/Views/_ViewImports.cshtml index 622fc8b6cd0..7f8293fbd60 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentPreview/Views/_ViewImports.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.ContentPreview/Views/_ViewImports.cshtml @@ -1,7 +1,3 @@ -@* - For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 - -*@ @using Microsoft.AspNetCore.Authorization @inherits OrchardCore.DisplayManagement.Razor.RazorPage diff --git a/src/OrchardCore.Modules/OrchardCore.ContentTypes/Views/_ViewImports.cshtml b/src/OrchardCore.Modules/OrchardCore.ContentTypes/Views/_ViewImports.cshtml index 0cb774da678..16cbf30fed7 100644 --- a/src/OrchardCore.Modules/OrchardCore.ContentTypes/Views/_ViewImports.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.ContentTypes/Views/_ViewImports.cshtml @@ -1,8 +1,3 @@ -@* - For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 - -*@ - @inherits OrchardCore.DisplayManagement.Razor.RazorPage @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @addTagHelper *, OrchardCore.DisplayManagement diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Views/_ViewImports.cshtml b/src/OrchardCore.Modules/OrchardCore.Contents/Views/_ViewImports.cshtml index 5e3024d7cac..a56b0158486 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Views/_ViewImports.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Views/_ViewImports.cshtml @@ -1,7 +1,3 @@ -@* - For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 - -*@ @using Microsoft.AspNetCore.Authorization @using Microsoft.AspNetCore.Routing @using Microsoft.AspNetCore.Mvc.Localization diff --git a/src/OrchardCore.Modules/OrchardCore.CustomSettings/Views/_ViewImports.cshtml b/src/OrchardCore.Modules/OrchardCore.CustomSettings/Views/_ViewImports.cshtml index 945a8f806fe..5c115046b82 100644 --- a/src/OrchardCore.Modules/OrchardCore.CustomSettings/Views/_ViewImports.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.CustomSettings/Views/_ViewImports.cshtml @@ -1,8 +1,3 @@ -@* - For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 - -*@ - @inherits OrchardCore.DisplayManagement.Razor.RazorPage @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers @addTagHelper *, OrchardCore.DisplayManagement diff --git a/src/OrchardCore.Modules/OrchardCore.Google/Views/_ViewImports.cshtml b/src/OrchardCore.Modules/OrchardCore.Google/Views/_ViewImports.cshtml index 4769da1c181..378f7f6e58f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Google/Views/_ViewImports.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Google/Views/_ViewImports.cshtml @@ -1,7 +1,3 @@ -@* - For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 - -*@ @inherits OrchardCore.DisplayManagement.Razor.RazorPage @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Views/_ViewImports.cshtml b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Views/_ViewImports.cshtml index 4769da1c181..378f7f6e58f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Views/_ViewImports.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Microsoft.Authentication/Views/_ViewImports.cshtml @@ -1,7 +1,3 @@ -@* - For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 - -*@ @inherits OrchardCore.DisplayManagement.Razor.RazorPage @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/src/OrchardCore.Modules/OrchardCore.OpenId/Views/_ViewImports.cshtml b/src/OrchardCore.Modules/OrchardCore.OpenId/Views/_ViewImports.cshtml index 4769da1c181..378f7f6e58f 100644 --- a/src/OrchardCore.Modules/OrchardCore.OpenId/Views/_ViewImports.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.OpenId/Views/_ViewImports.cshtml @@ -1,7 +1,3 @@ -@* - For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 - -*@ @inherits OrchardCore.DisplayManagement.Razor.RazorPage @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/src/OrchardCore.Modules/OrchardCore.ReverseProxy/Views/_ViewImports.cshtml b/src/OrchardCore.Modules/OrchardCore.ReverseProxy/Views/_ViewImports.cshtml index 12125c06702..f3d71640e2e 100644 --- a/src/OrchardCore.Modules/OrchardCore.ReverseProxy/Views/_ViewImports.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.ReverseProxy/Views/_ViewImports.cshtml @@ -1,7 +1,3 @@ -@* - For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 - -*@ @inherits OrchardCore.DisplayManagement.Razor.RazorPage @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Views/_ViewImports.cshtml b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Views/_ViewImports.cshtml index b8b85ae30dc..731736ae4d1 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Views/_ViewImports.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Search.Elasticsearch/Views/_ViewImports.cshtml @@ -1,7 +1,3 @@ -@* - For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 - -*@ @inherits OrchardCore.DisplayManagement.Razor.RazorPage @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Views/_ViewImports.cshtml b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Views/_ViewImports.cshtml index 9b0e953dbdf..45c96b4d624 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Views/_ViewImports.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Search.Lucene/Views/_ViewImports.cshtml @@ -1,7 +1,3 @@ -@* - For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 - -*@ @inherits OrchardCore.DisplayManagement.Razor.RazorPage @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/src/OrchardCore.Modules/OrchardCore.Search/Views/_ViewImports.cshtml b/src/OrchardCore.Modules/OrchardCore.Search/Views/_ViewImports.cshtml index 8b5c37647e4..51321a460b3 100644 --- a/src/OrchardCore.Modules/OrchardCore.Search/Views/_ViewImports.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Search/Views/_ViewImports.cshtml @@ -1,7 +1,3 @@ -@* - For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 - -*@ @inherits OrchardCore.DisplayManagement.Razor.RazorPage @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/src/OrchardCore.Modules/OrchardCore.Settings/Views/_ViewImports.cshtml b/src/OrchardCore.Modules/OrchardCore.Settings/Views/_ViewImports.cshtml index 7a0445166c7..1b89e95c347 100644 --- a/src/OrchardCore.Modules/OrchardCore.Settings/Views/_ViewImports.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Settings/Views/_ViewImports.cshtml @@ -1,7 +1,3 @@ -@* - For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 - -*@ @inherits OrchardCore.DisplayManagement.Razor.RazorPage @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/src/OrchardCore.Modules/OrchardCore.Sitemaps/Views/_ViewImports.cshtml b/src/OrchardCore.Modules/OrchardCore.Sitemaps/Views/_ViewImports.cshtml index 6463c4bd906..b705dd80a1e 100644 --- a/src/OrchardCore.Modules/OrchardCore.Sitemaps/Views/_ViewImports.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Sitemaps/Views/_ViewImports.cshtml @@ -1,7 +1,3 @@ -@* - For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 - -*@ @inherits OrchardCore.DisplayManagement.Razor.RazorPage diff --git a/src/OrchardCore.Modules/OrchardCore.Spatial/Views/_ViewImports.cshtml b/src/OrchardCore.Modules/OrchardCore.Spatial/Views/_ViewImports.cshtml index 34bf2e890f1..2863dff018a 100644 --- a/src/OrchardCore.Modules/OrchardCore.Spatial/Views/_ViewImports.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Spatial/Views/_ViewImports.cshtml @@ -1,7 +1,3 @@ -@* - For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 - -*@ @inherits OrchardCore.DisplayManagement.Razor.RazorPage @using OrchardCore.DisplayManagement diff --git a/src/OrchardCore.Modules/OrchardCore.Themes/Views/_ViewImports.cshtml b/src/OrchardCore.Modules/OrchardCore.Themes/Views/_ViewImports.cshtml index ae74345f4db..22ebf0ff1be 100644 --- a/src/OrchardCore.Modules/OrchardCore.Themes/Views/_ViewImports.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Themes/Views/_ViewImports.cshtml @@ -1,7 +1,3 @@ -@* - For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 - -*@ @inherits OrchardCore.DisplayManagement.Razor.RazorPage @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/src/OrchardCore.Modules/OrchardCore.Title/Views/_ViewImports.cshtml b/src/OrchardCore.Modules/OrchardCore.Title/Views/_ViewImports.cshtml index 616d19468d9..37c447b868a 100644 --- a/src/OrchardCore.Modules/OrchardCore.Title/Views/_ViewImports.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Title/Views/_ViewImports.cshtml @@ -1,7 +1,3 @@ -@* - For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 - -*@ @inherits OrchardCore.DisplayManagement.Razor.RazorPage @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/src/OrchardCore.Modules/OrchardCore.Twitter/Views/_ViewImports.cshtml b/src/OrchardCore.Modules/OrchardCore.Twitter/Views/_ViewImports.cshtml index 4769da1c181..378f7f6e58f 100644 --- a/src/OrchardCore.Modules/OrchardCore.Twitter/Views/_ViewImports.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Twitter/Views/_ViewImports.cshtml @@ -1,7 +1,3 @@ -@* - For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 - -*@ @inherits OrchardCore.DisplayManagement.Razor.RazorPage @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/src/OrchardCore.Modules/OrchardCore.Users/Views/_ViewImports.cshtml b/src/OrchardCore.Modules/OrchardCore.Users/Views/_ViewImports.cshtml index 904487cf470..6cdf3fd8b78 100644 --- a/src/OrchardCore.Modules/OrchardCore.Users/Views/_ViewImports.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Users/Views/_ViewImports.cshtml @@ -1,7 +1,3 @@ -@* - For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 - -*@ @inherits OrchardCore.DisplayManagement.Razor.RazorPage @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/src/OrchardCore.Modules/OrchardCore.Widgets/Views/_ViewImports.cshtml b/src/OrchardCore.Modules/OrchardCore.Widgets/Views/_ViewImports.cshtml index bc7f70aaf9a..c063b4f6115 100644 --- a/src/OrchardCore.Modules/OrchardCore.Widgets/Views/_ViewImports.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.Widgets/Views/_ViewImports.cshtml @@ -1,7 +1,3 @@ -@* - For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 - -*@ @inherits OrchardCore.DisplayManagement.Razor.RazorPage @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers diff --git a/src/Templates/OrchardCore.ProjectTemplates/content/OrchardCore.Templates.Cms.Module/Views/_ViewImports.cshtml b/src/Templates/OrchardCore.ProjectTemplates/content/OrchardCore.Templates.Cms.Module/Views/_ViewImports.cshtml index 2de803cafe5..3e94a446810 100644 --- a/src/Templates/OrchardCore.ProjectTemplates/content/OrchardCore.Templates.Cms.Module/Views/_ViewImports.cshtml +++ b/src/Templates/OrchardCore.ProjectTemplates/content/OrchardCore.Templates.Cms.Module/Views/_ViewImports.cshtml @@ -1,7 +1,3 @@ -@* - For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860 - -*@ @inherits OrchardCore.DisplayManagement.Razor.RazorPage @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers From 9a5d118cfadd7a1958fa11f690d68e0d0e853e0a Mon Sep 17 00:00:00 2001 From: Hisham Bin Ateya Date: Wed, 13 Nov 2024 18:24:22 +0300 Subject: [PATCH 15/63] Remove extra semi-colon in OpenIdServerSettings.cshtml (#17007) --- .../OrchardCore.OpenId/Views/OpenIdServerSettings.Edit.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OrchardCore.Modules/OrchardCore.OpenId/Views/OpenIdServerSettings.Edit.cshtml b/src/OrchardCore.Modules/OrchardCore.OpenId/Views/OpenIdServerSettings.Edit.cshtml index 6f9bada6a05..e76114eef71 100644 --- a/src/OrchardCore.Modules/OrchardCore.OpenId/Views/OpenIdServerSettings.Edit.cshtml +++ b/src/OrchardCore.Modules/OrchardCore.OpenId/Views/OpenIdServerSettings.Edit.cshtml @@ -246,7 +246,7 @@ var friendlyName = certificate.FriendlyName; if (string.IsNullOrWhiteSpace(friendlyName) && !string.IsNullOrWhiteSpace(certificate.ThumbPrint)) { - friendlyName = T["No Friendly Name"].Value; ; + friendlyName = T["No Friendly Name"].Value; }