diff --git a/.editorconfig b/.editorconfig index 05f57f4..5c097b7 100644 --- a/.editorconfig +++ b/.editorconfig @@ -146,9 +146,6 @@ dotnet_diagnostic.IDE0079.severity = warn dotnet_style_prefer_simplified_interpolation = true : error dotnet_diagnostic.IDE0071.severity = error -csharp_style_namespace_declarations = file_scoped : error -dotnet_diagnostic.IDE0161.severity = error - ## Rules without Style Options # IDE0010: Add missing cases @@ -271,6 +268,12 @@ dotnet_diagnostic.IDE0056.severity = warn csharp_style_prefer_range_operator = true : warning dotnet_diagnostic.IDE0057.severity = warning +csharp_style_namespace_declarations = file_scoped : error +dotnet_diagnostic.IDE0161.severity = error + +csharp_style_prefer_null_check_over_type_check = true : warning +dotnet_diagnostic.IDE0150.severity = error + ## Rules without Style Options # IDE0050: Convert anonymous type to tuple diff --git a/src/Kentico.Xperience.Lucene.Examples/KBankNews/KBankNewsLuceneIndexingStrategy.cs b/src/Kentico.Xperience.Lucene.Examples/KBankNews/KBankNewsLuceneIndexingStrategy.cs index 38a820b..346462b 100644 --- a/src/Kentico.Xperience.Lucene.Examples/KBankNews/KBankNewsLuceneIndexingStrategy.cs +++ b/src/Kentico.Xperience.Lucene.Examples/KBankNews/KBankNewsLuceneIndexingStrategy.cs @@ -17,7 +17,7 @@ public class KBankNewsLuceneIndexingStrategy : DefaultLuceneIndexingStrategy object? result = foundValue; if (propertyName == nameof(KBankNewsSearchModel.AllContent)) { - var htmlSanitizer = Service.Resolve(); + var htmlSanitizer = Service.Resolve(); result = string.Join(" ", contentFields .Select(f => node.GetStringValue(f, "")) .Select(s => htmlSanitizer.SanitizeHtmlFragment(s)) diff --git a/src/Kentico.Xperience.Lucene.Examples/Utils/HtmlSanitizer.cs b/src/Kentico.Xperience.Lucene.Examples/Utils/WebScraperHtmlSanitizer.cs similarity index 87% rename from src/Kentico.Xperience.Lucene.Examples/Utils/HtmlSanitizer.cs rename to src/Kentico.Xperience.Lucene.Examples/Utils/WebScraperHtmlSanitizer.cs index 108e145..3305904 100644 --- a/src/Kentico.Xperience.Lucene.Examples/Utils/HtmlSanitizer.cs +++ b/src/Kentico.Xperience.Lucene.Examples/Utils/WebScraperHtmlSanitizer.cs @@ -1,12 +1,17 @@ using AngleSharp.Dom; using AngleSharp.Html.Parser; +using CMS; +using CMS.Core; using CMS.Helpers; +using Kentico.Xperience.Lucene.Examples.Utils; + +[assembly: RegisterImplementation(typeof(WebScraperHtmlSanitizer), typeof(WebScraperHtmlSanitizer), Lifestyle = Lifestyle.Singleton, Priority = RegistrationPriority.SystemDefault)] namespace Kentico.Xperience.Lucene.Examples.Utils; -public class HtmlSanitizer +public class WebScraperHtmlSanitizer { - public static string SanitizeHtmlFragment(string htmlContent) + public virtual string SanitizeHtmlFragment(string htmlContent) { var parser = new HtmlParser(); diff --git a/src/Kentico.Xperience.Lucene/CmsRegistrations.cs b/src/Kentico.Xperience.Lucene/CmsRegistrations.cs index b8e9a9b..978d79d 100644 --- a/src/Kentico.Xperience.Lucene/CmsRegistrations.cs +++ b/src/Kentico.Xperience.Lucene/CmsRegistrations.cs @@ -10,8 +10,6 @@ using Kentico.Xperience.Lucene.Services; using Kentico.Xperience.Lucene.Services.Implementations; -[assembly: AssemblyDiscoverable] - // Allows the Lucene test project to read internal members [assembly: InternalsVisibleTo("Kentico.Xperience.Lucene.Tests")] diff --git a/src/Kentico.Xperience.Lucene/IndexStore.cs b/src/Kentico.Xperience.Lucene/IndexStore.cs index ee4aefa..bfd2762 100644 --- a/src/Kentico.Xperience.Lucene/IndexStore.cs +++ b/src/Kentico.Xperience.Lucene/IndexStore.cs @@ -31,7 +31,7 @@ public void AddIndex(LuceneIndex index) throw new ArgumentNullException(nameof(index)); } - if (registeredIndexes.Any(i => i.IndexName.Equals(index.IndexName, StringComparison.OrdinalIgnoreCase))) + if (registeredIndexes.Exists(i => i.IndexName.Equals(index.IndexName, StringComparison.OrdinalIgnoreCase))) { throw new InvalidOperationException($"Attempted to register Lucene index with name '{index.IndexName},' but it is already registered."); } diff --git a/src/Kentico.Xperience.Lucene/Services/ILuceneTaskLogger.cs b/src/Kentico.Xperience.Lucene/Services/ILuceneTaskLogger.cs index eff0470..44b96fa 100644 --- a/src/Kentico.Xperience.Lucene/Services/ILuceneTaskLogger.cs +++ b/src/Kentico.Xperience.Lucene/Services/ILuceneTaskLogger.cs @@ -5,13 +5,13 @@ namespace Kentico.Xperience.Lucene.Services; /// -/// Contains methods for logging s and s -/// for processing by and . +/// Contains methods for logging s and s +/// for processing by and . /// public interface ILuceneTaskLogger { /// - /// Logs an for each registered crawler. Then, loops + /// Logs an for each registered crawler. Then, loops /// through all registered Lucene indexes and logs a task if the passed is indexed. /// /// The that triggered the event. diff --git a/src/Kentico.Xperience.Lucene/Services/Implementations/DefaultLuceneClient.cs b/src/Kentico.Xperience.Lucene/Services/Implementations/DefaultLuceneClient.cs index fd3eb13..e2f51f3 100644 --- a/src/Kentico.Xperience.Lucene/Services/Implementations/DefaultLuceneClient.cs +++ b/src/Kentico.Xperience.Lucene/Services/Implementations/DefaultLuceneClient.cs @@ -64,15 +64,16 @@ public Task DeleteRecords(IEnumerable objectIds, string indexName) /// - public async Task> GetStatistics(CancellationToken cancellationToken) => IndexStore.Instance.GetAllIndexes().Select(i => - { - var statistics = luceneIndexService.UseSearcher(i, s => new LuceneIndexStatisticsViewModel() - { - Name = i.IndexName, - Entries = s.IndexReader.NumDocs, - }); - return statistics; - }).ToList(); + public async Task> GetStatistics(CancellationToken cancellationToken) => + IndexStore.Instance.GetAllIndexes().Select(i => + { + var statistics = luceneIndexService.UseSearcher(i, s => new LuceneIndexStatisticsViewModel() + { + Name = i.IndexName, + Entries = s.IndexReader.NumDocs, + }); + return statistics; + }).ToList(); ///