From cf767e2deeadc4ac2bbd4832cc61f85370ee9d22 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sun, 23 Feb 2020 15:47:24 +0100 Subject: [PATCH] * TaskHelper removed * Cleanup in TextIndexers * Use secondary read preference for contents. --- .../Validators/AllowedValuesValidator.cs | 3 +- .../Validators/CollectionValidator.cs | 7 ++- .../Validators/PatternValidator.cs | 5 +- .../Validators/RangeValidator.cs | 3 +- .../Validators/RequiredStringValidator.cs | 5 +- .../Validators/RequiredValidator.cs | 5 +- .../Validators/StringLengthValidator.cs | 5 +- .../Validators/UniqueValuesValidator.cs | 5 +- .../Contents/MongoContentCollectionAll.cs | 2 +- .../MongoContentCollectionPublished.cs | 10 +++- .../Contents/MongoContentRepository.cs | 2 +- .../Contents/Operations/OperationBase.cs | 3 +- .../Operations/QueryContentsByQuery.cs | 4 +- .../FullText/MongoIndexStorage.cs | 8 +++ .../Assets/AssetUsageTracker_EventHandling.cs | 5 +- .../Assets/BackupAssets.cs | 3 +- .../Assets/FileTagAssetMetadataSource.cs | 3 +- .../Assets/FileTypeAssetMetadataSource.cs | 3 +- .../Assets/RecursiveDeleter.cs | 3 +- .../Backup/BackupGrain.cs | 2 +- .../Backup/BackupWriter.cs | 3 +- .../Backup/IBackupHandler.cs | 15 +++--- .../Backup/RestoreGrain.cs | 2 +- .../Contents/BackupContents.cs | 3 +- .../Contents/ContentOperationContext.cs | 5 +- .../Contents/ContentSchedulerGrain.cs | 5 +- .../Contents/ContentsSearchSource.cs | 4 +- .../Contents/DefaultContentWorkflow.cs | 3 +- .../Contents/Queries/IContentEnricherStep.cs | 3 +- .../Queries/Steps/EnrichForCaching.cs | 3 +- .../Text/Elastic/ElasticSearchTextIndex.cs | 7 ++- .../{IContentTextIndex.cs => ITextIndex.cs} | 4 +- .../Contents/Text/Lucene/IndexManager.cs | 17 +++--- .../Contents/Text/Lucene/LuceneTextIndex.cs | 13 ++++- .../Text/Lucene/Storage/AssetIndexStorage.cs | 5 ++ .../Text/Lucene/Storage/FileIndexStorage.cs | 5 ++ .../Text/Lucene/Storage/IIndexStorage.cs | 2 + .../Text/State/InMemoryTextIndexerState.cs | 7 ++- .../Contents/Text/TextIndexingProcess.cs | 13 ++--- .../NoopNotificationEmailSender.cs | 3 +- .../NotificationEmailEventConsumer.cs | 3 +- .../Rules/BackupRules.cs | 3 +- .../Rules/RuleDequeuerGrain.cs | 6 +-- .../Rules/RuleEnqueuer.cs | 3 +- .../Rules/UsageTracking/UsageTrackerGrain.cs | 7 ++- .../Schemas/BackupSchemas.cs | 3 +- .../MongoRoleStore.cs | 5 +- .../MongoUserStore.cs | 53 +++++++++---------- .../DefaultXmlRepository.cs | 4 +- .../CosmosDbEventStore_Reader.cs | 7 ++- .../EventSourcing/CosmosDbSubscription.cs | 3 +- .../GetEventStoreSubscription.cs | 3 +- .../MongoDb/MongoRepositoryBase.cs | 3 +- .../CQRS/Events/RabbitMqEventConsumer.cs | 7 ++- .../Assets/FolderAssetStore.cs | 7 ++- .../Assets/MemoryAssetStore.cs | 2 +- .../Commands/CommandExtensions.cs | 3 +- .../Commands/DomainObjectBase.cs | 2 +- .../Grains/EventConsumerGrain.cs | 10 ++-- .../LanguagesInitializer.cs | 3 +- .../Log/Store/BackgroundRequestLogStore.cs | 3 +- .../Orleans/ActivationLimit.cs | 6 +-- .../Orleans/GrainOfGuid.cs | 3 +- .../Orleans/GrainOfString.cs | 5 +- .../Orleans/Indexes/UniqueNameIndexGrain.cs | 3 +- .../Orleans/LockGrain.cs | 3 +- .../Tasks/SingleThreadedDispatcher.cs | 4 +- .../Tasks/TaskExtensions.cs | 2 +- .../Tasks/TaskHelper.cs | 27 ---------- .../UsageTracking/BackgroundUsageTracker.cs | 3 +- .../src/Squidex.Web/ApiPermissionAttribute.cs | 3 +- .../Controllers/Account/AccountController.cs | 3 +- .../Config/Authentication/GoogleHandler.cs | 3 +- .../Squidex/Config/Domain/ContentsServices.cs | 2 +- .../Config/Domain/SerializationInitializer.cs | 3 +- .../Config/Startup/LogConfigurationHost.cs | 3 +- .../Config/Startup/SafeHostedService.cs | 3 +- .../Assets/BackupAssetsTests.cs | 5 +- .../Backup/BackupReaderWriterTests.cs | 5 +- .../CommentsCommandMiddlewareTests.cs | 3 +- .../Contents/BackupContentsTests.cs | 3 +- .../Contents/ContentsSearchSourceTests.cs | 2 +- .../Contents/MongoDb/ContentsQueryFixture.cs | 4 +- .../Contents/MongoDb/ContentsQueryTests.cs | 3 +- .../Contents/Text/IIndexerFactory.cs | 2 +- .../Contents/Text/LuceneIndexFactory.cs | 8 +-- .../Commands/InMemoryCommandBusTests.cs | 5 +- .../Commands/LogCommandMiddlewareTests.cs | 5 +- .../ReadonlyCommandMiddlewareTests.cs | 3 +- .../EventSourcing/EventStoreTests.cs | 7 ++- .../Migrations/MigratorTests.cs | 3 +- .../MongoDb/MongoExtensionsTests.cs | 9 ++-- .../Tasks/SingleThreadedDispatcherTests.cs | 2 +- .../Timers/CompletionTimerTests.cs | 4 +- .../Pipeline/CleanupHostMiddlewareTests.cs | 3 +- .../Pipeline/EnforceHttpsMiddlewareTests.cs | 3 +- .../Migrations/PopulateGrainIndexes.cs | 7 ++- 97 files changed, 235 insertions(+), 275 deletions(-) rename backend/src/Squidex.Domain.Apps.Entities/Contents/Text/{IContentTextIndex.cs => ITextIndex.cs} (93%) delete mode 100644 backend/src/Squidex.Infrastructure/Tasks/TaskHelper.cs diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/AllowedValuesValidator.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/AllowedValuesValidator.cs index 680ee979c..583744302 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/AllowedValuesValidator.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/AllowedValuesValidator.cs @@ -9,7 +9,6 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Squidex.Infrastructure; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Apps.Core.ValidateContent.Validators { @@ -36,7 +35,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators addError(context.Path, "Not an allowed value."); } - return TaskHelper.Done; + return Task.CompletedTask; } } } \ No newline at end of file diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/CollectionValidator.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/CollectionValidator.cs index 65ddf8311..3c2d16a7c 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/CollectionValidator.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/CollectionValidator.cs @@ -8,7 +8,6 @@ using System; using System.Collections; using System.Threading.Tasks; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Apps.Core.ValidateContent.Validators { @@ -39,7 +38,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators addError(context.Path, "Field is required."); } - return TaskHelper.Done; + return Task.CompletedTask; } if (minItems.HasValue && maxItems.HasValue) @@ -66,7 +65,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators } } - return TaskHelper.Done; + return Task.CompletedTask; } } -} +} \ No newline at end of file diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/PatternValidator.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/PatternValidator.cs index 97d9cf06d..a027d70d4 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/PatternValidator.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/PatternValidator.cs @@ -8,7 +8,6 @@ using System; using System.Text.RegularExpressions; using System.Threading.Tasks; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Apps.Core.ValidateContent.Validators { @@ -52,7 +51,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators } } - return TaskHelper.Done; + return Task.CompletedTask; } } -} +} \ No newline at end of file diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/RangeValidator.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/RangeValidator.cs index a1133f0c5..d733ff856 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/RangeValidator.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/RangeValidator.cs @@ -7,7 +7,6 @@ using System; using System.Threading.Tasks; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Apps.Core.ValidateContent.Validators { @@ -56,7 +55,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators } } - return TaskHelper.Done; + return Task.CompletedTask; } } } diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/RequiredStringValidator.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/RequiredStringValidator.cs index 97e411a09..d169d0258 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/RequiredStringValidator.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/RequiredStringValidator.cs @@ -6,7 +6,6 @@ // ========================================================================== using System.Threading.Tasks; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Apps.Core.ValidateContent.Validators { @@ -23,7 +22,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators { if (context.IsOptional) { - return TaskHelper.Done; + return Task.CompletedTask; } if (value.IsNullOrUndefined() || IsEmptyString(value)) @@ -31,7 +30,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators addError(context.Path, "Field is required."); } - return TaskHelper.Done; + return Task.CompletedTask; } private bool IsEmptyString(object? value) diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/RequiredValidator.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/RequiredValidator.cs index ef9cf1027..8e9440cf7 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/RequiredValidator.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/RequiredValidator.cs @@ -6,7 +6,6 @@ // ========================================================================== using System.Threading.Tasks; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Apps.Core.ValidateContent.Validators { @@ -19,7 +18,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators addError(context.Path, "Field is required."); } - return TaskHelper.Done; + return Task.CompletedTask; } } -} +} \ No newline at end of file diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/StringLengthValidator.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/StringLengthValidator.cs index 08be9d0b0..ad33e9de0 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/StringLengthValidator.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/StringLengthValidator.cs @@ -7,7 +7,6 @@ using System; using System.Threading.Tasks; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Apps.Core.ValidateContent.Validators { @@ -56,7 +55,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators } } - return TaskHelper.Done; + return Task.CompletedTask; } } -} +} \ No newline at end of file diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/UniqueValuesValidator.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/UniqueValuesValidator.cs index c9e9f724f..266be2748 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/UniqueValuesValidator.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/UniqueValuesValidator.cs @@ -8,7 +8,6 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Apps.Core.ValidateContent.Validators { @@ -26,7 +25,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators } } - return TaskHelper.Done; + return Task.CompletedTask; } } -} +} \ No newline at end of file diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentCollectionAll.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentCollectionAll.cs index 62bed7107..a3d92612a 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentCollectionAll.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentCollectionAll.cs @@ -33,7 +33,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents private readonly QueryIdsAsync queryIdsAsync; private readonly QueryScheduledContents queryScheduledItems; - public MongoContentCollectionAll(IMongoDatabase database, IAppProvider appProvider, IContentTextIndex indexer, IJsonSerializer serializer) + public MongoContentCollectionAll(IMongoDatabase database, IAppProvider appProvider, ITextIndex indexer, IJsonSerializer serializer) : base(database) { queryContentAsync = new QueryContent(serializer); diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentCollectionPublished.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentCollectionPublished.cs index ed56c0d22..49ec31214 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentCollectionPublished.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentCollectionPublished.cs @@ -31,7 +31,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents private readonly QueryContentsByQuery queryContentsByQuery; private readonly QueryIdsAsync queryIdsAsync; - public MongoContentCollectionPublished(IMongoDatabase database, IAppProvider appProvider, IContentTextIndex indexer, IJsonSerializer serializer) + public MongoContentCollectionPublished(IMongoDatabase database, IAppProvider appProvider, ITextIndex indexer, IJsonSerializer serializer) : base(database) { queryContentAsync = new QueryContent(serializer); @@ -45,6 +45,14 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents return Collection; } + protected override MongoCollectionSettings CollectionSettings() + { + return new MongoCollectionSettings + { + ReadPreference = ReadPreference.SecondaryPreferred.With(TimeSpan.FromSeconds(10)) + }; + } + protected override string CollectionName() { return "State_Contents_Published"; diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentRepository.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentRepository.cs index 1a9772001..1cfd4805f 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentRepository.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentRepository.cs @@ -34,7 +34,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents StatusSerializer.Register(); } - public MongoContentRepository(IMongoDatabase database, IAppProvider appProvider, IContentTextIndex indexer, IJsonSerializer serializer) + public MongoContentRepository(IMongoDatabase database, IAppProvider appProvider, ITextIndex indexer, IJsonSerializer serializer) { Guard.NotNull(appProvider); Guard.NotNull(serializer); diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/OperationBase.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/OperationBase.cs index 127948ec1..90f40738c 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/OperationBase.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/OperationBase.cs @@ -9,7 +9,6 @@ using System.Threading; using System.Threading.Tasks; using MongoDB.Driver; using Squidex.Infrastructure.MongoDb; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Apps.Entities.MongoDb.Contents.Operations { @@ -33,7 +32,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents.Operations protected virtual Task PrepareAsync(CancellationToken ct = default) { - return TaskHelper.Done; + return Task.CompletedTask; } } } diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryContentsByQuery.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryContentsByQuery.cs index 0f52efc69..18c8312b2 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryContentsByQuery.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryContentsByQuery.cs @@ -24,9 +24,9 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents.Operations internal sealed class QueryContentsByQuery : OperationBase { private readonly IJsonSerializer serializer; - private readonly IContentTextIndex indexer; + private readonly ITextIndex indexer; - public QueryContentsByQuery(IJsonSerializer serializer, IContentTextIndex indexer) + public QueryContentsByQuery(IJsonSerializer serializer, ITextIndex indexer) { this.serializer = serializer; diff --git a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/FullText/MongoIndexStorage.cs b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/FullText/MongoIndexStorage.cs index a100269ca..b9781f871 100644 --- a/backend/src/Squidex.Domain.Apps.Entities.MongoDb/FullText/MongoIndexStorage.cs +++ b/backend/src/Squidex.Domain.Apps.Entities.MongoDb/FullText/MongoIndexStorage.cs @@ -11,6 +11,7 @@ using System.Threading.Tasks; using Lucene.Net.Index; using MongoDB.Driver.GridFS; using Squidex.Domain.Apps.Entities.Contents.Text.Lucene; +using Squidex.Infrastructure; using LuceneDirectory = Lucene.Net.Store.Directory; namespace Squidex.Domain.Apps.Entities.MongoDb.FullText @@ -21,6 +22,8 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.FullText public MongoIndexStorage(IGridFSBucket bucket) { + Guard.NotNull(bucket); + this.bucket = bucket; } @@ -36,6 +39,11 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.FullText return Task.FromResult(directory); } + public Task ClearAsync() + { + return bucket.DropAsync(); + } + public Task WriteAsync(LuceneDirectory directory, SnapshotDeletionPolicy snapshotter) { return Task.CompletedTask; diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/AssetUsageTracker_EventHandling.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/AssetUsageTracker_EventHandling.cs index f8083077f..3f1a98949 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Assets/AssetUsageTracker_EventHandling.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Assets/AssetUsageTracker_EventHandling.cs @@ -9,7 +9,6 @@ using System; using System.Threading.Tasks; using Squidex.Domain.Apps.Events.Assets; using Squidex.Infrastructure.EventSourcing; -using Squidex.Infrastructure.Tasks; using Squidex.Infrastructure.UsageTracking; namespace Squidex.Domain.Apps.Entities.Assets @@ -33,7 +32,7 @@ namespace Squidex.Domain.Apps.Entities.Assets public Task ClearAsync() { - return TaskHelper.Done; + return Task.CompletedTask; } public Task On(Envelope @event) @@ -50,7 +49,7 @@ namespace Squidex.Domain.Apps.Entities.Assets return UpdateSizeAsync(e.AppId.Id, GetDate(@event), e.DeletedSize, -1); } - return TaskHelper.Done; + return Task.CompletedTask; } private static DateTime GetDate(Envelope @event) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/BackupAssets.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/BackupAssets.cs index 4eed3f7a0..61df1d02f 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Assets/BackupAssets.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Assets/BackupAssets.cs @@ -15,7 +15,6 @@ using Squidex.Domain.Apps.Events.Assets; using Squidex.Infrastructure; using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.EventSourcing; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Apps.Entities.Assets { @@ -56,7 +55,7 @@ namespace Squidex.Domain.Apps.Entities.Assets return WriteAssetAsync(assetUpdated.AssetId, assetUpdated.FileVersion, context.Writer); } - return TaskHelper.Done; + return Task.CompletedTask; } public async Task RestoreEventAsync(Envelope @event, RestoreContext context) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/FileTagAssetMetadataSource.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/FileTagAssetMetadataSource.cs index 6ea42efe3..ee54868d1 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Assets/FileTagAssetMetadataSource.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Assets/FileTagAssetMetadataSource.cs @@ -14,7 +14,6 @@ using Squidex.Domain.Apps.Entities.Assets.Commands; using Squidex.Infrastructure; using Squidex.Infrastructure.Assets; using Squidex.Infrastructure.Json.Objects; -using Squidex.Infrastructure.Tasks; using TagLib; using TagLib.Image; using static TagLib.File; @@ -57,7 +56,7 @@ namespace Squidex.Domain.Apps.Entities.Assets { Enhance(command); - return TaskHelper.Done; + return Task.CompletedTask; } private void Enhance(UploadAssetCommand command) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/FileTypeAssetMetadataSource.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/FileTypeAssetMetadataSource.cs index 39f950630..92f603a52 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Assets/FileTypeAssetMetadataSource.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Assets/FileTypeAssetMetadataSource.cs @@ -9,7 +9,6 @@ using System.Collections.Generic; using System.Threading.Tasks; using Squidex.Domain.Apps.Entities.Assets.Commands; using Squidex.Infrastructure; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Apps.Entities.Assets { @@ -27,7 +26,7 @@ namespace Squidex.Domain.Apps.Entities.Assets } } - return TaskHelper.Done; + return Task.CompletedTask; } public IEnumerable Format(IAssetEntity asset) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/RecursiveDeleter.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/RecursiveDeleter.cs index c687d9183..34402d7ad 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Assets/RecursiveDeleter.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Assets/RecursiveDeleter.cs @@ -15,7 +15,6 @@ using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.Log; using Squidex.Infrastructure.Reflection; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Apps.Entities.Assets { @@ -60,7 +59,7 @@ namespace Squidex.Domain.Apps.Entities.Assets public Task ClearAsync() { - return TaskHelper.Done; + return Task.CompletedTask; } public bool Handles(StoredEvent @event) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupGrain.cs b/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupGrain.cs index f72253cdf..ad877e48b 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupGrain.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupGrain.cs @@ -78,7 +78,7 @@ namespace Squidex.Domain.Apps.Entities.Backup { RecoverAfterRestartAsync().Forget(); - return TaskHelper.Done; + return Task.CompletedTask; } private async Task RecoverAfterRestartAsync() diff --git a/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupWriter.cs b/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupWriter.cs index e344b35cc..2067137a1 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupWriter.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Backup/BackupWriter.cs @@ -14,7 +14,6 @@ using Squidex.Domain.Apps.Entities.Backup.Model; using Squidex.Infrastructure; using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.Json; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Apps.Entities.Backup { @@ -71,7 +70,7 @@ namespace Squidex.Domain.Apps.Entities.Backup writtenAttachments++; - return TaskHelper.Done; + return Task.CompletedTask; } public async Task WriteBlobAsync(string name, Func handler) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Backup/IBackupHandler.cs b/backend/src/Squidex.Domain.Apps.Entities/Backup/IBackupHandler.cs index ee328dca6..89729e121 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Backup/IBackupHandler.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Backup/IBackupHandler.cs @@ -8,7 +8,6 @@ using System; using System.Threading.Tasks; using Squidex.Infrastructure.EventSourcing; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Apps.Entities.Backup { @@ -18,37 +17,37 @@ namespace Squidex.Domain.Apps.Entities.Backup public Task RestoreEventAsync(Envelope @event, RestoreContext context) { - return TaskHelper.True; + return Task.FromResult(true); } public Task BackupEventAsync(Envelope @event, BackupContext context) { - return TaskHelper.Done; + return Task.CompletedTask; } public Task RestoreAsync(RestoreContext context) { - return TaskHelper.Done; + return Task.CompletedTask; } public Task BackupAsync(BackupContext context) { - return TaskHelper.Done; + return Task.CompletedTask; } public Task CleanupRestoreErrorAsync(Guid appId) { - return TaskHelper.Done; + return Task.CompletedTask; } public Task CompleteRestoreAsync(RestoreContext context) { - return TaskHelper.Done; + return Task.CompletedTask; } public Task CompleteBackupAsync(BackupContext context) { - return TaskHelper.Done; + return Task.CompletedTask; } } } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Backup/RestoreGrain.cs b/backend/src/Squidex.Domain.Apps.Entities/Backup/RestoreGrain.cs index ea42baed8..2831fda7b 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Backup/RestoreGrain.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Backup/RestoreGrain.cs @@ -85,7 +85,7 @@ namespace Squidex.Domain.Apps.Entities.Backup { RecoverAfterRestartAsync().Forget(); - return TaskHelper.Done; + return Task.CompletedTask; } private async Task RecoverAfterRestartAsync() diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/BackupContents.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/BackupContents.cs index 47b5c3d45..4cc0d228b 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/BackupContents.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/BackupContents.cs @@ -16,7 +16,6 @@ using Squidex.Domain.Apps.Events.Schemas; using Squidex.Infrastructure; using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.EventSourcing; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Apps.Entities.Contents { @@ -46,7 +45,7 @@ namespace Squidex.Domain.Apps.Entities.Contents break; } - return TaskHelper.True; + return Task.FromResult(true); } public async Task RestoreAsync(RestoreContext context) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/ContentOperationContext.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/ContentOperationContext.cs index 18aa3da50..f79d792e8 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/ContentOperationContext.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/ContentOperationContext.cs @@ -19,7 +19,6 @@ using Squidex.Domain.Apps.Entities.Contents.Commands; using Squidex.Domain.Apps.Entities.Contents.Repositories; using Squidex.Domain.Apps.Entities.Schemas; using Squidex.Infrastructure.Queries; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Apps.Entities.Contents { @@ -80,7 +79,7 @@ namespace Squidex.Domain.Apps.Entities.Contents { data.GenerateDefaultValues(schemaEntity.SchemaDef, appEntity.PartitionResolver()); - return TaskHelper.Done; + return Task.CompletedTask; } public Task ValidateAsync(NamedContentData data, bool optimized) @@ -112,7 +111,7 @@ namespace Squidex.Domain.Apps.Entities.Contents scriptEngine.Execute(context, GetScript(script)); - return TaskHelper.Done; + return Task.CompletedTask; } private void Enrich(ScriptContext context) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/ContentSchedulerGrain.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/ContentSchedulerGrain.cs index c63c25a81..583828c53 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/ContentSchedulerGrain.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/ContentSchedulerGrain.cs @@ -16,7 +16,6 @@ using Squidex.Domain.Apps.Entities.Contents.Repositories; using Squidex.Infrastructure; using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Log; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Apps.Entities.Contents { @@ -61,7 +60,7 @@ namespace Squidex.Domain.Apps.Entities.Contents public Task ActivateAsync() { - return TaskHelper.Done; + return Task.CompletedTask; } public Task PublishAsync() @@ -96,7 +95,7 @@ namespace Squidex.Domain.Apps.Entities.Contents public Task ReceiveReminder(string reminderName, TickStatus status) { - return TaskHelper.Done; + return Task.CompletedTask; } private Task Dispatch(Func task) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/ContentsSearchSource.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/ContentsSearchSource.cs index 3bc0347d1..942e5527c 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/ContentsSearchSource.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/ContentsSearchSource.cs @@ -25,13 +25,13 @@ namespace Squidex.Domain.Apps.Entities.Contents { private readonly IAppProvider appProvider; private readonly IContentQueryService contentQuery; - private readonly IContentTextIndex contentTextIndexer; + private readonly ITextIndex contentTextIndexer; private readonly IUrlGenerator urlGenerator; public ContentsSearchSource( IAppProvider appProvider, IContentQueryService contentQuery, - IContentTextIndex contentTextIndexer, + ITextIndex contentTextIndexer, IUrlGenerator urlGenerator) { Guard.NotNull(appProvider); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/DefaultContentWorkflow.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/DefaultContentWorkflow.cs index 0c5da9820..16a5de6d5 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/DefaultContentWorkflow.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/DefaultContentWorkflow.cs @@ -12,7 +12,6 @@ using System.Security.Claims; using System.Threading.Tasks; using Squidex.Domain.Apps.Core.Contents; using Squidex.Domain.Apps.Entities.Schemas; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Apps.Entities.Contents { @@ -55,7 +54,7 @@ namespace Squidex.Domain.Apps.Entities.Contents public Task CanPublishOnCreateAsync(ISchemaEntity schema, NamedContentData data, ClaimsPrincipal user) { - return TaskHelper.True; + return Task.FromResult(true); } public Task CanMoveToAsync(IContentEntity content, Status status, Status next, ClaimsPrincipal user) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/IContentEnricherStep.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/IContentEnricherStep.cs index c51386628..c750f3902 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/IContentEnricherStep.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/IContentEnricherStep.cs @@ -9,7 +9,6 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; using Squidex.Domain.Apps.Entities.Schemas; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Apps.Entities.Contents.Queries { @@ -21,7 +20,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries Task EnrichAsync(Context context) { - return TaskHelper.Done; + return Task.CompletedTask; } } } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/EnrichForCaching.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/EnrichForCaching.cs index dd2b592e0..ce41cfff6 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/EnrichForCaching.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/EnrichForCaching.cs @@ -10,7 +10,6 @@ using System.Linq; using System.Threading.Tasks; using Squidex.Infrastructure; using Squidex.Infrastructure.Caching; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Apps.Entities.Contents.Queries.Steps { @@ -29,7 +28,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries.Steps { context.AddCacheHeaders(requestCache); - return TaskHelper.Done; + return Task.CompletedTask; } public async Task EnrichAsync(Context context, IEnumerable contents, ProvideSchema schemas) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Elastic/ElasticSearchTextIndex.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Elastic/ElasticSearchTextIndex.cs index e7553156b..6fa9c1ffc 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Elastic/ElasticSearchTextIndex.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Elastic/ElasticSearchTextIndex.cs @@ -16,7 +16,7 @@ using Squidex.Infrastructure; namespace Squidex.Domain.Apps.Entities.Contents.Text.Elastic { [ExcludeFromCodeCoverage] - public sealed class ElasticSearchTextIndex : IContentTextIndex + public sealed class ElasticSearchTextIndex : ITextIndex { private const string IndexName = "contents"; private readonly ElasticLowLevelClient client; @@ -28,6 +28,11 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.Elastic client = new ElasticLowLevelClient(config); } + public Task ClearAsync() + { + return Task.CompletedTask; + } + public async Task ExecuteAsync(NamedId appId, NamedId schemaId, params IndexCommand[] commands) { foreach (var command in commands) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/IContentTextIndex.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/ITextIndex.cs similarity index 93% rename from backend/src/Squidex.Domain.Apps.Entities/Contents/Text/IContentTextIndex.cs rename to backend/src/Squidex.Domain.Apps.Entities/Contents/Text/ITextIndex.cs index f7fcab656..fd4d8c7e9 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/IContentTextIndex.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/ITextIndex.cs @@ -13,10 +13,12 @@ using Squidex.Infrastructure; namespace Squidex.Domain.Apps.Entities.Contents.Text { - public interface IContentTextIndex + public interface ITextIndex { Task?> SearchAsync(string? queryText, IAppEntity app, SearchFilter? filter, SearchScope scope); + Task ClearAsync(); + Task ExecuteAsync(NamedId appId, NamedId schemaId, params IndexCommand[] commands); } } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Lucene/IndexManager.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Lucene/IndexManager.cs index a556177e4..ae3b707f8 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Lucene/IndexManager.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Lucene/IndexManager.cs @@ -19,15 +19,15 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.Lucene { private readonly Dictionary indices = new Dictionary(); private readonly SemaphoreSlim lockObject = new SemaphoreSlim(1); - private readonly IIndexStorage directoryFactory; + private readonly IIndexStorage indexStorage; private readonly ISemanticLog log; - public IndexManager(IIndexStorage directoryFactory, ISemanticLog log) + public IndexManager(IIndexStorage indexStorage, ISemanticLog log) { - Guard.NotNull(directoryFactory); + Guard.NotNull(indexStorage); Guard.NotNull(log); - this.directoryFactory = directoryFactory; + this.indexStorage = indexStorage; this.log = log; } @@ -40,6 +40,11 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.Lucene } } + public Task ClearAsync() + { + return indexStorage.ClearAsync(); + } + public async Task AcquireAsync(Guid schemaId) { IndexHolder? indexHolder; @@ -65,7 +70,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.Lucene lockObject.Release(); } - var directory = await directoryFactory.CreateDirectoryAsync(schemaId); + var directory = await indexStorage.CreateDirectoryAsync(schemaId); indexHolder.Open(directory); @@ -113,7 +118,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.Lucene holder.Commit(); } - await directoryFactory.WriteAsync(holder.GetUnsafeWriter().Directory, holder.Snapshotter); + await indexStorage.WriteAsync(holder.GetUnsafeWriter().Directory, holder.Snapshotter); } } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Lucene/LuceneTextIndex.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Lucene/LuceneTextIndex.cs index a117a3a94..e6cc8f8d4 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Lucene/LuceneTextIndex.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Lucene/LuceneTextIndex.cs @@ -16,15 +16,24 @@ using Squidex.Infrastructure.Log; namespace Squidex.Domain.Apps.Entities.Contents.Text.Lucene { - public sealed class LuceneTextIndex : IContentTextIndex + public sealed class LuceneTextIndex : ITextIndex { private readonly IGrainFactory grainFactory; + private readonly IndexManager indexManager; - public LuceneTextIndex(IGrainFactory grainFactory) + public LuceneTextIndex(IGrainFactory grainFactory, IndexManager indexManager) { Guard.NotNull(grainFactory); + Guard.NotNull(indexManager); this.grainFactory = grainFactory; + + this.indexManager = indexManager; + } + + public Task ClearAsync() + { + return indexManager.ClearAsync(); } public async Task?> SearchAsync(string? queryText, IAppEntity app, SearchFilter? filter, SearchScope scope) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Lucene/Storage/AssetIndexStorage.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Lucene/Storage/AssetIndexStorage.cs index c62d5b395..ce4871a18 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Lucene/Storage/AssetIndexStorage.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Lucene/Storage/AssetIndexStorage.cs @@ -64,6 +64,11 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.Lucene.Storage return directory; } + public Task ClearAsync() + { + return Task.CompletedTask; + } + public async Task WriteAsync(LuceneDirectory directory, SnapshotDeletionPolicy snapshotter) { Guard.NotNull(directory); diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Lucene/Storage/FileIndexStorage.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Lucene/Storage/FileIndexStorage.cs index 3f2462801..489092cc2 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Lucene/Storage/FileIndexStorage.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Lucene/Storage/FileIndexStorage.cs @@ -24,6 +24,11 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.Lucene.Storage return Task.FromResult(FSDirectory.Open(folderPath)); } + public Task ClearAsync() + { + return Task.CompletedTask; + } + public Task WriteAsync(LuceneDirectory directory, SnapshotDeletionPolicy snapshotter) { return Task.CompletedTask; diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Lucene/Storage/IIndexStorage.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Lucene/Storage/IIndexStorage.cs index da75976cd..b88caa993 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Lucene/Storage/IIndexStorage.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Lucene/Storage/IIndexStorage.cs @@ -16,6 +16,8 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.Lucene { Task CreateDirectoryAsync(Guid schemaId); + Task ClearAsync(); + Task WriteAsync(Directory directory, SnapshotDeletionPolicy snapshotter); } } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/State/InMemoryTextIndexerState.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/State/InMemoryTextIndexerState.cs index 25d2a6de1..017102b36 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/State/InMemoryTextIndexerState.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/State/InMemoryTextIndexerState.cs @@ -8,7 +8,6 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Apps.Entities.Contents.Text.State { @@ -20,7 +19,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.State { states.Clear(); - return TaskHelper.Done; + return Task.CompletedTask; } public Task GetAsync(Guid contentId) @@ -37,14 +36,14 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.State { states.Remove(contentId); - return TaskHelper.Done; + return Task.CompletedTask; } public Task SetAsync(TextContentState state) { states[state.ContentId] = state; - return TaskHelper.Done; + return Task.CompletedTask; } } } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/TextIndexingProcess.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/TextIndexingProcess.cs index 7b8f46f7a..1e67bc7a0 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/TextIndexingProcess.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/Text/TextIndexingProcess.cs @@ -17,12 +17,12 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text public sealed class TextIndexingProcess : IEventConsumer { private const string NotFound = "<404>"; - private readonly IContentTextIndex textIndexer; + private readonly ITextIndex textIndexer; private readonly ITextIndexerState textIndexerState; public string Name { - get { return "TextIndexer2"; } + get { return "TextIndexer3"; } } public string EventsFilter @@ -30,12 +30,12 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text get { return "^content-"; } } - public IContentTextIndex TextIndexer + public ITextIndex TextIndexer { get { return textIndexer; } } - public TextIndexingProcess(IContentTextIndex textIndexer, ITextIndexerState textIndexerState) + public TextIndexingProcess(ITextIndex textIndexer, ITextIndexerState textIndexerState) { Guard.NotNull(textIndexer); Guard.NotNull(textIndexerState); @@ -49,9 +49,10 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text return true; } - public Task ClearAsync() + public async Task ClearAsync() { - return textIndexerState.ClearAsync(); + await textIndexer.ClearAsync(); + await textIndexerState.ClearAsync(); } public async Task On(Envelope @event) diff --git a/backend/src/Squidex.Domain.Apps.Entities/History/Notifications/NoopNotificationEmailSender.cs b/backend/src/Squidex.Domain.Apps.Entities/History/Notifications/NoopNotificationEmailSender.cs index f970ecb59..306b9d90b 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/History/Notifications/NoopNotificationEmailSender.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/History/Notifications/NoopNotificationEmailSender.cs @@ -6,7 +6,6 @@ // ========================================================================== using System.Threading.Tasks; -using Squidex.Infrastructure.Tasks; using Squidex.Shared.Users; namespace Squidex.Domain.Apps.Entities.History.Notifications @@ -20,7 +19,7 @@ namespace Squidex.Domain.Apps.Entities.History.Notifications public Task SendContributorEmailAsync(IUser assigner, IUser assignee, string appName, bool isCreated) { - return TaskHelper.Done; + return Task.CompletedTask; } } } diff --git a/backend/src/Squidex.Domain.Apps.Entities/History/Notifications/NotificationEmailEventConsumer.cs b/backend/src/Squidex.Domain.Apps.Entities/History/Notifications/NotificationEmailEventConsumer.cs index a521530a6..a5d942914 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/History/Notifications/NotificationEmailEventConsumer.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/History/Notifications/NotificationEmailEventConsumer.cs @@ -11,7 +11,6 @@ using Squidex.Domain.Apps.Events.Apps; using Squidex.Infrastructure; using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.Log; -using Squidex.Infrastructure.Tasks; using Squidex.Shared.Users; namespace Squidex.Domain.Apps.Entities.History.Notifications @@ -52,7 +51,7 @@ namespace Squidex.Domain.Apps.Entities.History.Notifications public Task ClearAsync() { - return TaskHelper.Done; + return Task.CompletedTask; } public async Task On(Envelope @event) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Rules/BackupRules.cs b/backend/src/Squidex.Domain.Apps.Entities/Rules/BackupRules.cs index b46a75ea2..fc8f38390 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Rules/BackupRules.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Rules/BackupRules.cs @@ -13,7 +13,6 @@ using Squidex.Domain.Apps.Entities.Rules.Indexes; using Squidex.Domain.Apps.Events.Rules; using Squidex.Infrastructure; using Squidex.Infrastructure.EventSourcing; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Apps.Entities.Rules { @@ -43,7 +42,7 @@ namespace Squidex.Domain.Apps.Entities.Rules break; } - return TaskHelper.True; + return Task.FromResult(true); } public Task RestoreAsync(RestoreContext context) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Rules/RuleDequeuerGrain.cs b/backend/src/Squidex.Domain.Apps.Entities/Rules/RuleDequeuerGrain.cs index 87d72761d..12644c78f 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Rules/RuleDequeuerGrain.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Rules/RuleDequeuerGrain.cs @@ -56,7 +56,7 @@ namespace Squidex.Domain.Apps.Entities.Rules RegisterOrUpdateReminder("Default", TimeSpan.Zero, TimeSpan.FromMinutes(10)); RegisterTimer(x => QueryAsync(), null, TimeSpan.Zero, TimeSpan.FromSeconds(10)); - return TaskHelper.Done; + return Task.CompletedTask; } public override Task OnDeactivateAsync() @@ -68,7 +68,7 @@ namespace Squidex.Domain.Apps.Entities.Rules public Task ActivateAsync() { - return TaskHelper.Done; + return Task.CompletedTask; } public async Task QueryAsync() @@ -157,7 +157,7 @@ namespace Squidex.Domain.Apps.Entities.Rules public Task ReceiveReminder(string reminderName, TickStatus status) { - return TaskHelper.Done; + return Task.CompletedTask; } } } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Rules/RuleEnqueuer.cs b/backend/src/Squidex.Domain.Apps.Entities/Rules/RuleEnqueuer.cs index 0ade4c788..80f20a853 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Rules/RuleEnqueuer.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Rules/RuleEnqueuer.cs @@ -15,7 +15,6 @@ using Squidex.Domain.Apps.Entities.Rules.Repositories; using Squidex.Domain.Apps.Events; using Squidex.Infrastructure; using Squidex.Infrastructure.EventSourcing; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Apps.Entities.Rules { @@ -60,7 +59,7 @@ namespace Squidex.Domain.Apps.Entities.Rules public Task ClearAsync() { - return TaskHelper.Done; + return Task.CompletedTask; } public async Task Enqueue(Rule rule, Guid ruleId, Envelope @event) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Rules/UsageTracking/UsageTrackerGrain.cs b/backend/src/Squidex.Domain.Apps.Entities/Rules/UsageTracking/UsageTrackerGrain.cs index 3f3990dd2..2c9678328 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Rules/UsageTracking/UsageTrackerGrain.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Rules/UsageTracking/UsageTrackerGrain.cs @@ -16,7 +16,6 @@ using Squidex.Infrastructure; using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.Orleans; using Squidex.Infrastructure.States; -using Squidex.Infrastructure.Tasks; using Squidex.Infrastructure.UsageTracking; namespace Squidex.Domain.Apps.Entities.Rules.UsageTracking @@ -61,17 +60,17 @@ namespace Squidex.Domain.Apps.Entities.Rules.UsageTracking RegisterOrUpdateReminder("Default", TimeSpan.Zero, TimeSpan.FromMinutes(10)); RegisterTimer(x => CheckUsagesAsync(), null, TimeSpan.Zero, TimeSpan.FromMinutes(10)); - return TaskHelper.Done; + return Task.CompletedTask; } public Task ActivateAsync() { - return TaskHelper.Done; + return Task.CompletedTask; } public Task ReceiveReminder(string reminderName, TickStatus status) { - return TaskHelper.Done; + return Task.CompletedTask; } public async Task CheckUsagesAsync() diff --git a/backend/src/Squidex.Domain.Apps.Entities/Schemas/BackupSchemas.cs b/backend/src/Squidex.Domain.Apps.Entities/Schemas/BackupSchemas.cs index 9a722fe36..55bd2b732 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Schemas/BackupSchemas.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Schemas/BackupSchemas.cs @@ -13,7 +13,6 @@ using Squidex.Domain.Apps.Entities.Schemas.Indexes; using Squidex.Domain.Apps.Events.Schemas; using Squidex.Infrastructure; using Squidex.Infrastructure.EventSourcing; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Apps.Entities.Schemas { @@ -43,7 +42,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas break; } - return TaskHelper.True; + return Task.FromResult(true); } public Task RestoreAsync(RestoreContext context) diff --git a/backend/src/Squidex.Domain.Users.MongoDb/MongoRoleStore.cs b/backend/src/Squidex.Domain.Users.MongoDb/MongoRoleStore.cs index 22f239f52..7368744de 100644 --- a/backend/src/Squidex.Domain.Users.MongoDb/MongoRoleStore.cs +++ b/backend/src/Squidex.Domain.Users.MongoDb/MongoRoleStore.cs @@ -13,7 +13,6 @@ using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; using MongoDB.Driver; using Squidex.Infrastructure.MongoDb; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Users.MongoDb { @@ -119,14 +118,14 @@ namespace Squidex.Domain.Users.MongoDb { role.Name = roleName; - return TaskHelper.Done; + return Task.CompletedTask; } public Task SetNormalizedRoleNameAsync(IdentityRole role, string normalizedName, CancellationToken cancellationToken) { role.NormalizedName = normalizedName; - return TaskHelper.Done; + return Task.CompletedTask; } } } \ No newline at end of file diff --git a/backend/src/Squidex.Domain.Users.MongoDb/MongoUserStore.cs b/backend/src/Squidex.Domain.Users.MongoDb/MongoUserStore.cs index 0ce10e3c3..25f086ae2 100644 --- a/backend/src/Squidex.Domain.Users.MongoDb/MongoUserStore.cs +++ b/backend/src/Squidex.Domain.Users.MongoDb/MongoUserStore.cs @@ -17,7 +17,6 @@ using MongoDB.Bson.Serialization; using MongoDB.Bson.Serialization.Serializers; using MongoDB.Driver; using Squidex.Infrastructure.MongoDb; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Users.MongoDb { @@ -354,126 +353,126 @@ namespace Squidex.Domain.Users.MongoDb { ((MongoUser)user).UserName = userName; - return TaskHelper.Done; + return Task.CompletedTask; } public Task SetNormalizedUserNameAsync(IdentityUser user, string normalizedName, CancellationToken cancellationToken) { ((MongoUser)user).NormalizedUserName = normalizedName; - return TaskHelper.Done; + return Task.CompletedTask; } public Task SetPasswordHashAsync(IdentityUser user, string passwordHash, CancellationToken cancellationToken) { ((MongoUser)user).PasswordHash = passwordHash; - return TaskHelper.Done; + return Task.CompletedTask; } public Task AddToRoleAsync(IdentityUser user, string roleName, CancellationToken cancellationToken) { ((MongoUser)user).AddRole(roleName); - return TaskHelper.Done; + return Task.CompletedTask; } public Task RemoveFromRoleAsync(IdentityUser user, string roleName, CancellationToken cancellationToken) { ((MongoUser)user).RemoveRole(roleName); - return TaskHelper.Done; + return Task.CompletedTask; } public Task AddLoginAsync(IdentityUser user, UserLoginInfo login, CancellationToken cancellationToken) { ((MongoUser)user).AddLogin(login); - return TaskHelper.Done; + return Task.CompletedTask; } public Task RemoveLoginAsync(IdentityUser user, string loginProvider, string providerKey, CancellationToken cancellationToken) { ((MongoUser)user).RemoveLogin(loginProvider, providerKey); - return TaskHelper.Done; + return Task.CompletedTask; } public Task SetSecurityStampAsync(IdentityUser user, string stamp, CancellationToken cancellationToken) { ((MongoUser)user).SecurityStamp = stamp; - return TaskHelper.Done; + return Task.CompletedTask; } public Task SetEmailAsync(IdentityUser user, string email, CancellationToken cancellationToken) { ((MongoUser)user).Email = email; - return TaskHelper.Done; + return Task.CompletedTask; } public Task SetEmailConfirmedAsync(IdentityUser user, bool confirmed, CancellationToken cancellationToken) { ((MongoUser)user).EmailConfirmed = confirmed; - return TaskHelper.Done; + return Task.CompletedTask; } public Task SetNormalizedEmailAsync(IdentityUser user, string normalizedEmail, CancellationToken cancellationToken) { ((MongoUser)user).NormalizedEmail = normalizedEmail; - return TaskHelper.Done; + return Task.CompletedTask; } public Task AddClaimsAsync(IdentityUser user, IEnumerable claims, CancellationToken cancellationToken) { ((MongoUser)user).AddClaims(claims); - return TaskHelper.Done; + return Task.CompletedTask; } public Task ReplaceClaimAsync(IdentityUser user, Claim claim, Claim newClaim, CancellationToken cancellationToken) { ((MongoUser)user).ReplaceClaim(claim, newClaim); - return TaskHelper.Done; + return Task.CompletedTask; } public Task RemoveClaimsAsync(IdentityUser user, IEnumerable claims, CancellationToken cancellationToken) { ((MongoUser)user).RemoveClaims(claims); - return TaskHelper.Done; + return Task.CompletedTask; } public Task SetPhoneNumberAsync(IdentityUser user, string phoneNumber, CancellationToken cancellationToken) { ((MongoUser)user).PhoneNumber = phoneNumber; - return TaskHelper.Done; + return Task.CompletedTask; } public Task SetPhoneNumberConfirmedAsync(IdentityUser user, bool confirmed, CancellationToken cancellationToken) { ((MongoUser)user).PhoneNumberConfirmed = confirmed; - return TaskHelper.Done; + return Task.CompletedTask; } public Task SetTwoFactorEnabledAsync(IdentityUser user, bool enabled, CancellationToken cancellationToken) { ((MongoUser)user).TwoFactorEnabled = enabled; - return TaskHelper.Done; + return Task.CompletedTask; } public Task SetLockoutEndDateAsync(IdentityUser user, DateTimeOffset? lockoutEnd, CancellationToken cancellationToken) { ((MongoUser)user).LockoutEnd = lockoutEnd?.UtcDateTime; - return TaskHelper.Done; + return Task.CompletedTask; } public Task IncrementAccessFailedCountAsync(IdentityUser user, CancellationToken cancellationToken) @@ -487,42 +486,42 @@ namespace Squidex.Domain.Users.MongoDb { ((MongoUser)user).AccessFailedCount = 0; - return TaskHelper.Done; + return Task.CompletedTask; } public Task SetLockoutEnabledAsync(IdentityUser user, bool enabled, CancellationToken cancellationToken) { ((MongoUser)user).LockoutEnabled = enabled; - return TaskHelper.Done; + return Task.CompletedTask; } public Task SetTokenAsync(IdentityUser user, string loginProvider, string name, string value, CancellationToken cancellationToken) { ((MongoUser)user).SetToken(loginProvider, name, value); - return TaskHelper.Done; + return Task.CompletedTask; } public Task RemoveTokenAsync(IdentityUser user, string loginProvider, string name, CancellationToken cancellationToken) { ((MongoUser)user).RemoveToken(loginProvider, name); - return TaskHelper.Done; + return Task.CompletedTask; } public Task SetAuthenticatorKeyAsync(IdentityUser user, string key, CancellationToken cancellationToken) { ((MongoUser)user).SetToken(InternalLoginProvider, AuthenticatorKeyTokenName, key); - return TaskHelper.Done; + return Task.CompletedTask; } public Task ReplaceCodesAsync(IdentityUser user, IEnumerable recoveryCodes, CancellationToken cancellationToken) { ((MongoUser)user).SetToken(InternalLoginProvider, RecoveryCodeTokenName, string.Join(";", recoveryCodes)); - return TaskHelper.Done; + return Task.CompletedTask; } public Task RedeemCodeAsync(IdentityUser user, string code, CancellationToken cancellationToken) @@ -536,10 +535,10 @@ namespace Squidex.Domain.Users.MongoDb ((MongoUser)user).SetToken(InternalLoginProvider, RecoveryCodeTokenName, string.Join(";", updatedCodes)); - return TaskHelper.True; + return Task.FromResult(true); } - return TaskHelper.False; + return Task.FromResult(false); } } } \ No newline at end of file diff --git a/backend/src/Squidex.Domain.Users/DefaultXmlRepository.cs b/backend/src/Squidex.Domain.Users/DefaultXmlRepository.cs index 621d45153..929e686a2 100644 --- a/backend/src/Squidex.Domain.Users/DefaultXmlRepository.cs +++ b/backend/src/Squidex.Domain.Users/DefaultXmlRepository.cs @@ -6,11 +6,11 @@ // ========================================================================== using System.Collections.Generic; +using System.Threading.Tasks; using System.Xml.Linq; using Microsoft.AspNetCore.DataProtection.Repositories; using Squidex.Infrastructure; using Squidex.Infrastructure.States; -using Squidex.Infrastructure.Tasks; namespace Squidex.Domain.Users { @@ -39,7 +39,7 @@ namespace Squidex.Domain.Users { result.Add(XElement.Parse(state.Xml)); - return TaskHelper.Done; + return Task.CompletedTask; }).Wait(); return result; diff --git a/backend/src/Squidex.Infrastructure.Azure/EventSourcing/CosmosDbEventStore_Reader.cs b/backend/src/Squidex.Infrastructure.Azure/EventSourcing/CosmosDbEventStore_Reader.cs index 48dd81e7c..a1164be89 100644 --- a/backend/src/Squidex.Infrastructure.Azure/EventSourcing/CosmosDbEventStore_Reader.cs +++ b/backend/src/Squidex.Infrastructure.Azure/EventSourcing/CosmosDbEventStore_Reader.cs @@ -12,7 +12,6 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.Documents; using Squidex.Infrastructure.Log; -using Squidex.Infrastructure.Tasks; namespace Squidex.Infrastructure.EventSourcing { @@ -37,7 +36,7 @@ namespace Squidex.Infrastructure.EventSourcing ThrowIfDisposed(); - return TaskHelper.Done; + return Task.CompletedTask; } public async Task> QueryLatestAsync(string streamName, int count) @@ -74,7 +73,7 @@ namespace Squidex.Infrastructure.EventSourcing result.Add(new StoredEvent(streamName, eventToken, eventStreamOffset, eventData)); } - return TaskHelper.Done; + return Task.CompletedTask; }); IEnumerable ordered = result.OrderBy(x => x.EventStreamNumber); @@ -120,7 +119,7 @@ namespace Squidex.Infrastructure.EventSourcing } } - return TaskHelper.Done; + return Task.CompletedTask; }); return result; diff --git a/backend/src/Squidex.Infrastructure.Azure/EventSourcing/CosmosDbSubscription.cs b/backend/src/Squidex.Infrastructure.Azure/EventSourcing/CosmosDbSubscription.cs index d4403489c..407d526d6 100644 --- a/backend/src/Squidex.Infrastructure.Azure/EventSourcing/CosmosDbSubscription.cs +++ b/backend/src/Squidex.Infrastructure.Azure/EventSourcing/CosmosDbSubscription.cs @@ -13,7 +13,6 @@ using System.Threading.Tasks; using Microsoft.Azure.Documents; using Microsoft.Azure.Documents.ChangeFeedProcessor.FeedProcessing; using Newtonsoft.Json; -using Squidex.Infrastructure.Tasks; using Builder = Microsoft.Azure.Documents.ChangeFeedProcessor.ChangeFeedProcessorBuilder; using Collection = Microsoft.Azure.Documents.ChangeFeedProcessor.DocumentCollectionInfo; using Options = Microsoft.Azure.Documents.ChangeFeedProcessor.ChangeFeedProcessorOptions; @@ -104,7 +103,7 @@ namespace Squidex.Infrastructure.EventSourcing public Task OpenAsync(IChangeFeedObserverContext context) { - return TaskHelper.Done; + return Task.CompletedTask; } public async Task ProcessChangesAsync(IChangeFeedObserverContext context, IReadOnlyList docs, CancellationToken cancellationToken) diff --git a/backend/src/Squidex.Infrastructure.GetEventStore/EventSourcing/GetEventStoreSubscription.cs b/backend/src/Squidex.Infrastructure.GetEventStore/EventSourcing/GetEventStoreSubscription.cs index 3fa20e8ae..08f317743 100644 --- a/backend/src/Squidex.Infrastructure.GetEventStore/EventSourcing/GetEventStoreSubscription.cs +++ b/backend/src/Squidex.Infrastructure.GetEventStore/EventSourcing/GetEventStoreSubscription.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using EventStore.ClientAPI; using EventStore.ClientAPI.Exceptions; using Squidex.Infrastructure.Json; -using Squidex.Infrastructure.Tasks; namespace Squidex.Infrastructure.EventSourcing { @@ -48,7 +47,7 @@ namespace Squidex.Infrastructure.EventSourcing { subscription.Stop(); - return TaskHelper.Done; + return Task.CompletedTask; } public void WakeUp() diff --git a/backend/src/Squidex.Infrastructure.MongoDb/MongoDb/MongoRepositoryBase.cs b/backend/src/Squidex.Infrastructure.MongoDb/MongoDb/MongoRepositoryBase.cs index c4fbc2619..3d7a48bd3 100644 --- a/backend/src/Squidex.Infrastructure.MongoDb/MongoDb/MongoRepositoryBase.cs +++ b/backend/src/Squidex.Infrastructure.MongoDb/MongoDb/MongoRepositoryBase.cs @@ -10,7 +10,6 @@ using System.Globalization; using System.Threading; using System.Threading.Tasks; using MongoDB.Driver; -using Squidex.Infrastructure.Tasks; #pragma warning disable RECS0108 // Warns about static fields in generic types @@ -81,7 +80,7 @@ namespace Squidex.Infrastructure.MongoDb protected virtual Task SetupCollectionAsync(IMongoCollection collection, CancellationToken ct = default) { - return TaskHelper.Done; + return Task.CompletedTask; } public virtual async Task ClearAsync() diff --git a/backend/src/Squidex.Infrastructure.RabbitMq/CQRS/Events/RabbitMqEventConsumer.cs b/backend/src/Squidex.Infrastructure.RabbitMq/CQRS/Events/RabbitMqEventConsumer.cs index 4bbaaf222..cbfa6229a 100644 --- a/backend/src/Squidex.Infrastructure.RabbitMq/CQRS/Events/RabbitMqEventConsumer.cs +++ b/backend/src/Squidex.Infrastructure.RabbitMq/CQRS/Events/RabbitMqEventConsumer.cs @@ -12,7 +12,6 @@ using System.Threading.Tasks; using RabbitMQ.Client; using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.Json; -using Squidex.Infrastructure.Tasks; namespace Squidex.Infrastructure.CQRS.Events { @@ -73,7 +72,7 @@ namespace Squidex.Infrastructure.CQRS.Events throw new ConfigurationException($"RabbitMq event bus failed to connect to {connectionFactory.Endpoint}"); } - return TaskHelper.Done; + return Task.CompletedTask; } catch (Exception e) { @@ -88,7 +87,7 @@ namespace Squidex.Infrastructure.CQRS.Events public Task ClearAsync() { - return TaskHelper.Done; + return Task.CompletedTask; } public Task On(Envelope @event) @@ -98,7 +97,7 @@ namespace Squidex.Infrastructure.CQRS.Events channel.Value.BasicPublish(exchange, string.Empty, null, jsonBytes); - return TaskHelper.Done; + return Task.CompletedTask; } } } diff --git a/backend/src/Squidex.Infrastructure/Assets/FolderAssetStore.cs b/backend/src/Squidex.Infrastructure/Assets/FolderAssetStore.cs index 95d8ebdc6..4c8aa01df 100644 --- a/backend/src/Squidex.Infrastructure/Assets/FolderAssetStore.cs +++ b/backend/src/Squidex.Infrastructure/Assets/FolderAssetStore.cs @@ -10,7 +10,6 @@ using System.IO; using System.Threading; using System.Threading.Tasks; using Squidex.Infrastructure.Log; -using Squidex.Infrastructure.Tasks; namespace Squidex.Infrastructure.Assets { @@ -43,7 +42,7 @@ namespace Squidex.Infrastructure.Assets .WriteProperty("action", "FolderAssetStoreConfigured") .WriteProperty("path", directory.FullName)); - return TaskHelper.Done; + return Task.CompletedTask; } catch (Exception ex) { @@ -68,7 +67,7 @@ namespace Squidex.Infrastructure.Assets { sourceFile.CopyTo(targetFile.FullName); - return TaskHelper.Done; + return Task.CompletedTask; } catch (IOException) when (targetFile.Exists) { @@ -124,7 +123,7 @@ namespace Squidex.Infrastructure.Assets file.Delete(); - return TaskHelper.Done; + return Task.CompletedTask; } private FileInfo GetFile(string fileName) diff --git a/backend/src/Squidex.Infrastructure/Assets/MemoryAssetStore.cs b/backend/src/Squidex.Infrastructure/Assets/MemoryAssetStore.cs index 5e6feec8f..ec2535504 100644 --- a/backend/src/Squidex.Infrastructure/Assets/MemoryAssetStore.cs +++ b/backend/src/Squidex.Infrastructure/Assets/MemoryAssetStore.cs @@ -107,7 +107,7 @@ namespace Squidex.Infrastructure.Assets streams.TryRemove(fileName, out _); - return TaskHelper.Done; + return Task.CompletedTask; } } } diff --git a/backend/src/Squidex.Infrastructure/Commands/CommandExtensions.cs b/backend/src/Squidex.Infrastructure/Commands/CommandExtensions.cs index 2b3334dff..3326cd0d4 100644 --- a/backend/src/Squidex.Infrastructure/Commands/CommandExtensions.cs +++ b/backend/src/Squidex.Infrastructure/Commands/CommandExtensions.cs @@ -6,7 +6,6 @@ // ========================================================================== using System.Threading.Tasks; -using Squidex.Infrastructure.Tasks; namespace Squidex.Infrastructure.Commands { @@ -14,7 +13,7 @@ namespace Squidex.Infrastructure.Commands { public static Task HandleAsync(this ICommandMiddleware commandMiddleware, CommandContext context) { - return commandMiddleware.HandleAsync(context, x => TaskHelper.Done); + return commandMiddleware.HandleAsync(context, x => Task.CompletedTask); } } } diff --git a/backend/src/Squidex.Infrastructure/Commands/DomainObjectBase.cs b/backend/src/Squidex.Infrastructure/Commands/DomainObjectBase.cs index 3735c6d70..52e0dbaa5 100644 --- a/backend/src/Squidex.Infrastructure/Commands/DomainObjectBase.cs +++ b/backend/src/Squidex.Infrastructure/Commands/DomainObjectBase.cs @@ -209,7 +209,7 @@ namespace Squidex.Infrastructure.Commands public virtual Task RebuildStateAsync() { - return TaskHelper.Done; + return Task.CompletedTask; } protected virtual void OnSetup() diff --git a/backend/src/Squidex.Infrastructure/EventSourcing/Grains/EventConsumerGrain.cs b/backend/src/Squidex.Infrastructure/EventSourcing/Grains/EventConsumerGrain.cs index badbd0f7d..dbad484db 100644 --- a/backend/src/Squidex.Infrastructure/EventSourcing/Grains/EventConsumerGrain.cs +++ b/backend/src/Squidex.Infrastructure/EventSourcing/Grains/EventConsumerGrain.cs @@ -55,7 +55,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains eventConsumer = eventConsumerFactory(key); - return TaskHelper.Done; + return Task.CompletedTask; } public Task> GetStateAsync() @@ -72,7 +72,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains { if (subscription.Value != currentSubscription) { - return TaskHelper.Done; + return Task.CompletedTask; } return DoAndUpdateStateAsync(async () => @@ -95,7 +95,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains { if (subscription.Value != currentSubscription) { - return TaskHelper.Done; + return Task.CompletedTask; } return DoAndUpdateStateAsync(() => @@ -113,7 +113,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains Subscribe(state.Value.Position); } - return TaskHelper.Done; + return Task.CompletedTask; } public async Task> StartAsync() @@ -168,7 +168,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains private Task DoAndUpdateStateAsync(Action action, [CallerMemberName] string? caller = null) { - return DoAndUpdateStateAsync(() => { action(); return TaskHelper.Done; }, caller); + return DoAndUpdateStateAsync(() => { action(); return Task.CompletedTask; }, caller); } private async Task DoAndUpdateStateAsync(Func action, [CallerMemberName] string? caller = null) diff --git a/backend/src/Squidex.Infrastructure/LanguagesInitializer.cs b/backend/src/Squidex.Infrastructure/LanguagesInitializer.cs index bd8920f38..a018ba794 100644 --- a/backend/src/Squidex.Infrastructure/LanguagesInitializer.cs +++ b/backend/src/Squidex.Infrastructure/LanguagesInitializer.cs @@ -8,7 +8,6 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Options; -using Squidex.Infrastructure.Tasks; namespace Squidex.Infrastructure { @@ -33,7 +32,7 @@ namespace Squidex.Infrastructure } } - return TaskHelper.Done; + return Task.CompletedTask; } } } diff --git a/backend/src/Squidex.Infrastructure/Log/Store/BackgroundRequestLogStore.cs b/backend/src/Squidex.Infrastructure/Log/Store/BackgroundRequestLogStore.cs index 5299f0ecd..86766b13d 100644 --- a/backend/src/Squidex.Infrastructure/Log/Store/BackgroundRequestLogStore.cs +++ b/backend/src/Squidex.Infrastructure/Log/Store/BackgroundRequestLogStore.cs @@ -10,7 +10,6 @@ using System.Collections.Concurrent; using System.Linq; using System.Threading; using System.Threading.Tasks; -using Squidex.Infrastructure.Tasks; using Squidex.Infrastructure.Timers; namespace Squidex.Infrastructure.Log.Store @@ -85,7 +84,7 @@ namespace Squidex.Infrastructure.Log.Store jobs.Enqueue(request); - return TaskHelper.Done; + return Task.CompletedTask; } } } diff --git a/backend/src/Squidex.Infrastructure/Orleans/ActivationLimit.cs b/backend/src/Squidex.Infrastructure/Orleans/ActivationLimit.cs index f4f5e890c..14d858523 100644 --- a/backend/src/Squidex.Infrastructure/Orleans/ActivationLimit.cs +++ b/backend/src/Squidex.Infrastructure/Orleans/ActivationLimit.cs @@ -6,10 +6,10 @@ // ========================================================================== using System; +using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using Orleans; using Orleans.Runtime; -using Squidex.Infrastructure.Tasks; namespace Squidex.Infrastructure.Orleans { @@ -57,13 +57,13 @@ namespace Squidex.Infrastructure.Orleans ReportIAmAlive(); - return TaskHelper.Done; + return Task.CompletedTask; }, ct => { ReportIAmDead(); - return TaskHelper.Done; + return Task.CompletedTask; }); } diff --git a/backend/src/Squidex.Infrastructure/Orleans/GrainOfGuid.cs b/backend/src/Squidex.Infrastructure/Orleans/GrainOfGuid.cs index 689d0df57..deb81959f 100644 --- a/backend/src/Squidex.Infrastructure/Orleans/GrainOfGuid.cs +++ b/backend/src/Squidex.Infrastructure/Orleans/GrainOfGuid.cs @@ -10,7 +10,6 @@ using System.Threading.Tasks; using Orleans; using Orleans.Core; using Orleans.Runtime; -using Squidex.Infrastructure.Tasks; namespace Squidex.Infrastructure.Orleans { @@ -41,7 +40,7 @@ namespace Squidex.Infrastructure.Orleans protected virtual Task OnActivateAsync(Guid key) { - return TaskHelper.Done; + return Task.CompletedTask; } } } diff --git a/backend/src/Squidex.Infrastructure/Orleans/GrainOfString.cs b/backend/src/Squidex.Infrastructure/Orleans/GrainOfString.cs index 2d95eceb2..eba584a04 100644 --- a/backend/src/Squidex.Infrastructure/Orleans/GrainOfString.cs +++ b/backend/src/Squidex.Infrastructure/Orleans/GrainOfString.cs @@ -9,7 +9,6 @@ using System.Threading.Tasks; using Orleans; using Orleans.Core; using Orleans.Runtime; -using Squidex.Infrastructure.Tasks; namespace Squidex.Infrastructure.Orleans { @@ -41,12 +40,12 @@ namespace Squidex.Infrastructure.Orleans protected virtual Task OnLoadAsync(string key) { - return TaskHelper.Done; + return Task.CompletedTask; } protected virtual Task OnActivateAsync(string key) { - return TaskHelper.Done; + return Task.CompletedTask; } } } diff --git a/backend/src/Squidex.Infrastructure/Orleans/Indexes/UniqueNameIndexGrain.cs b/backend/src/Squidex.Infrastructure/Orleans/Indexes/UniqueNameIndexGrain.cs index ba2afdc3d..0b35ebcaf 100644 --- a/backend/src/Squidex.Infrastructure/Orleans/Indexes/UniqueNameIndexGrain.cs +++ b/backend/src/Squidex.Infrastructure/Orleans/Indexes/UniqueNameIndexGrain.cs @@ -9,7 +9,6 @@ using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using Orleans; -using Squidex.Infrastructure.Tasks; namespace Squidex.Infrastructure.Orleans.Indexes { @@ -80,7 +79,7 @@ namespace Squidex.Infrastructure.Orleans.Indexes { reservations.Remove(token ?? string.Empty); - return TaskHelper.Done; + return Task.CompletedTask; } public async Task RemoveAsync(T id) diff --git a/backend/src/Squidex.Infrastructure/Orleans/LockGrain.cs b/backend/src/Squidex.Infrastructure/Orleans/LockGrain.cs index 5c9d3f5be..fdcbb742a 100644 --- a/backend/src/Squidex.Infrastructure/Orleans/LockGrain.cs +++ b/backend/src/Squidex.Infrastructure/Orleans/LockGrain.cs @@ -9,7 +9,6 @@ using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; -using Squidex.Infrastructure.Tasks; namespace Squidex.Infrastructure.Orleans { @@ -40,7 +39,7 @@ namespace Squidex.Infrastructure.Orleans locks.Remove(key); } - return TaskHelper.Done; + return Task.CompletedTask; } } } diff --git a/backend/src/Squidex.Infrastructure/Tasks/SingleThreadedDispatcher.cs b/backend/src/Squidex.Infrastructure/Tasks/SingleThreadedDispatcher.cs index 244f2c96e..d6f57a403 100644 --- a/backend/src/Squidex.Infrastructure/Tasks/SingleThreadedDispatcher.cs +++ b/backend/src/Squidex.Infrastructure/Tasks/SingleThreadedDispatcher.cs @@ -39,7 +39,7 @@ namespace Squidex.Infrastructure.Tasks { Guard.NotNull(action); - return block.SendAsync(() => { action(); return TaskHelper.Done; }); + return block.SendAsync(() => { action(); return Task.CompletedTask; }); } public async Task StopAndWaitAsync() @@ -58,7 +58,7 @@ namespace Squidex.Infrastructure.Tasks { if (isStopped) { - return TaskHelper.Done; + return Task.CompletedTask; } return action(); diff --git a/backend/src/Squidex.Infrastructure/Tasks/TaskExtensions.cs b/backend/src/Squidex.Infrastructure/Tasks/TaskExtensions.cs index 4078d8e93..04e36f430 100644 --- a/backend/src/Squidex.Infrastructure/Tasks/TaskExtensions.cs +++ b/backend/src/Squidex.Infrastructure/Tasks/TaskExtensions.cs @@ -76,7 +76,7 @@ namespace Squidex.Infrastructure.Tasks { action(x); - return TaskHelper.Done; + return Task.CompletedTask; }; } diff --git a/backend/src/Squidex.Infrastructure/Tasks/TaskHelper.cs b/backend/src/Squidex.Infrastructure/Tasks/TaskHelper.cs deleted file mode 100644 index cf589d0ae..000000000 --- a/backend/src/Squidex.Infrastructure/Tasks/TaskHelper.cs +++ /dev/null @@ -1,27 +0,0 @@ -// ========================================================================== -// Squidex Headless CMS -// ========================================================================== -// Copyright (c) Squidex UG (haftungsbeschränkt) -// All rights reserved. Licensed under the MIT license. -// ========================================================================== - -using System.Threading.Tasks; - -namespace Squidex.Infrastructure.Tasks -{ - public static class TaskHelper - { - public static readonly Task Done = Task.CompletedTask; - public static readonly Task False = CreateResultTask(false); - public static readonly Task True = CreateResultTask(true); - - private static Task CreateResultTask(bool value) - { - var result = new TaskCompletionSource(); - - result.SetResult(value); - - return result.Task; - } - } -} \ No newline at end of file diff --git a/backend/src/Squidex.Infrastructure/UsageTracking/BackgroundUsageTracker.cs b/backend/src/Squidex.Infrastructure/UsageTracking/BackgroundUsageTracker.cs index 5e054c729..ea88c3405 100644 --- a/backend/src/Squidex.Infrastructure/UsageTracking/BackgroundUsageTracker.cs +++ b/backend/src/Squidex.Infrastructure/UsageTracking/BackgroundUsageTracker.cs @@ -12,7 +12,6 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using Squidex.Infrastructure.Log; -using Squidex.Infrastructure.Tasks; using Squidex.Infrastructure.Timers; namespace Squidex.Infrastructure.UsageTracking @@ -109,7 +108,7 @@ namespace Squidex.Infrastructure.UsageTracking usages.AddOrUpdate((key, category), _ => new Usage(elapsedMs, weight), (k, x) => x.Add(elapsedMs, weight)); } - return TaskHelper.Done; + return Task.CompletedTask; } public async Task>> QueryAsync(string key, DateTime fromDate, DateTime toDate) diff --git a/backend/src/Squidex.Web/ApiPermissionAttribute.cs b/backend/src/Squidex.Web/ApiPermissionAttribute.cs index a60d2826b..d983054da 100644 --- a/backend/src/Squidex.Web/ApiPermissionAttribute.cs +++ b/backend/src/Squidex.Web/ApiPermissionAttribute.cs @@ -11,7 +11,6 @@ using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; using Squidex.Infrastructure.Security; -using Squidex.Infrastructure.Tasks; namespace Squidex.Web { @@ -62,7 +61,7 @@ namespace Squidex.Web { context.Result = new StatusCodeResult(403); - return TaskHelper.Done; + return Task.CompletedTask; } } diff --git a/backend/src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs b/backend/src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs index 3a62627b9..b0008ae64 100644 --- a/backend/src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs +++ b/backend/src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs @@ -25,7 +25,6 @@ using Squidex.Config; using Squidex.Domain.Users; using Squidex.Infrastructure; using Squidex.Infrastructure.Log; -using Squidex.Infrastructure.Tasks; using Squidex.Shared; using Squidex.Shared.Identity; using Squidex.Shared.Users; @@ -352,7 +351,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Account { if (isFirst || !identityOptions.LockAutomatically) { - return TaskHelper.True; + return Task.FromResult(true); } return MakeIdentityOperation(() => userManager.SetLockoutEndDateAsync(user.Identity, DateTimeOffset.UtcNow.AddYears(100))); diff --git a/backend/src/Squidex/Config/Authentication/GoogleHandler.cs b/backend/src/Squidex/Config/Authentication/GoogleHandler.cs index d52aeb7ee..d09b3f12c 100644 --- a/backend/src/Squidex/Config/Authentication/GoogleHandler.cs +++ b/backend/src/Squidex/Config/Authentication/GoogleHandler.cs @@ -10,7 +10,6 @@ using System.Text.Json; using System.Threading.Tasks; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication.OAuth; -using Squidex.Infrastructure.Tasks; using Squidex.Shared.Identity; namespace Squidex.Config.Authentication @@ -21,7 +20,7 @@ namespace Squidex.Config.Authentication { context.Response.Redirect(context.RedirectUri + "&prompt=select_account"); - return TaskHelper.Done; + return Task.CompletedTask; } public override Task CreatingTicket(OAuthCreatingTicketContext context) diff --git a/backend/src/Squidex/Config/Domain/ContentsServices.cs b/backend/src/Squidex/Config/Domain/ContentsServices.cs index 2b808f27f..0bcc713a1 100644 --- a/backend/src/Squidex/Config/Domain/ContentsServices.cs +++ b/backend/src/Squidex/Config/Domain/ContentsServices.cs @@ -76,7 +76,7 @@ namespace Squidex.Config.Domain .AsOptional(); services.AddSingletonAs() - .As(); + .As(); services.AddSingletonAs() .As(); diff --git a/backend/src/Squidex/Config/Domain/SerializationInitializer.cs b/backend/src/Squidex/Config/Domain/SerializationInitializer.cs index 9d1bb868e..2aac58757 100644 --- a/backend/src/Squidex/Config/Domain/SerializationInitializer.cs +++ b/backend/src/Squidex/Config/Domain/SerializationInitializer.cs @@ -15,7 +15,6 @@ using Squidex.Infrastructure; using Squidex.Infrastructure.Json; using Squidex.Infrastructure.MongoDb; using Squidex.Infrastructure.Orleans; -using Squidex.Infrastructure.Tasks; namespace Squidex.Config.Domain { @@ -39,7 +38,7 @@ namespace Squidex.Config.Domain SetupOrleans(); SetupActions(); - return TaskHelper.Done; + return Task.CompletedTask; } private void SetupActions() diff --git a/backend/src/Squidex/Config/Startup/LogConfigurationHost.cs b/backend/src/Squidex/Config/Startup/LogConfigurationHost.cs index 6996f1435..40f08f273 100644 --- a/backend/src/Squidex/Config/Startup/LogConfigurationHost.cs +++ b/backend/src/Squidex/Config/Startup/LogConfigurationHost.cs @@ -12,7 +12,6 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Configuration; using Squidex.Infrastructure.Log; -using Squidex.Infrastructure.Tasks; namespace Squidex.Config.Startup { @@ -45,7 +44,7 @@ namespace Squidex.Config.Startup } })); - return TaskHelper.Done; + return Task.CompletedTask; } } } diff --git a/backend/src/Squidex/Config/Startup/SafeHostedService.cs b/backend/src/Squidex/Config/Startup/SafeHostedService.cs index 286d22dbf..b84981cc6 100644 --- a/backend/src/Squidex/Config/Startup/SafeHostedService.cs +++ b/backend/src/Squidex/Config/Startup/SafeHostedService.cs @@ -9,7 +9,6 @@ using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Hosting; using Squidex.Infrastructure.Log; -using Squidex.Infrastructure.Tasks; namespace Squidex.Config.Startup { @@ -42,7 +41,7 @@ namespace Squidex.Config.Startup protected virtual Task StopAsync(ISemanticLog log, CancellationToken ct) { - return TaskHelper.Done; + return Task.CompletedTask; } } } diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/BackupAssetsTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/BackupAssetsTests.cs index 2a926d50f..64cea944a 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/BackupAssetsTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/BackupAssetsTests.cs @@ -18,7 +18,6 @@ using Squidex.Domain.Apps.Events.Assets; using Squidex.Infrastructure; using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.EventSourcing; -using Squidex.Infrastructure.Tasks; using Xunit; #pragma warning disable IDE0067 // Dispose objects before losing scope @@ -175,7 +174,7 @@ namespace Squidex.Domain.Apps.Entities.Assets { rebuildAssets.Add(id); - return TaskHelper.Done; + return Task.CompletedTask; }); A.CallTo(() => rebuilder.InsertManyAsync(A._, A._)) @@ -219,7 +218,7 @@ namespace Squidex.Domain.Apps.Entities.Assets { rebuildAssets.Add(id); - return TaskHelper.Done; + return Task.CompletedTask; }); A.CallTo(() => rebuilder.InsertManyAsync(A._, A._)) diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Backup/BackupReaderWriterTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Backup/BackupReaderWriterTests.cs index 666c96e8c..118178dd1 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Backup/BackupReaderWriterTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Backup/BackupReaderWriterTests.cs @@ -17,7 +17,6 @@ using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.Json; using Squidex.Infrastructure.Reflection; using Squidex.Infrastructure.States; -using Squidex.Infrastructure.Tasks; using Xunit; namespace Squidex.Domain.Apps.Entities.Backup @@ -109,7 +108,7 @@ namespace Squidex.Domain.Apps.Entities.Backup { innerStream.WriteByte((byte)index); - return TaskHelper.Done; + return Task.CompletedTask; }); } else if (index % 37 == 0) @@ -139,7 +138,7 @@ namespace Squidex.Domain.Apps.Entities.Backup Assert.Equal((byte)index, byteRead); - return TaskHelper.Done; + return Task.CompletedTask; }); } else if (index % 37 == 0) diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Comments/CommentsCommandMiddlewareTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Comments/CommentsCommandMiddlewareTests.cs index fd17e0e22..9ba97c880 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Comments/CommentsCommandMiddlewareTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Comments/CommentsCommandMiddlewareTests.cs @@ -13,7 +13,6 @@ using Squidex.Domain.Apps.Entities.Comments.Commands; using Squidex.Infrastructure; using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Orleans; -using Squidex.Infrastructure.Tasks; using Squidex.Shared.Users; using Xunit; @@ -60,7 +59,7 @@ namespace Squidex.Domain.Apps.Entities.Comments { isNextCalled = true; - return TaskHelper.Done; + return Task.CompletedTask; }); Assert.True(isNextCalled); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/BackupContentsTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/BackupContentsTests.cs index 0ef5cb5e8..531ee2b4c 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/BackupContentsTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/BackupContentsTests.cs @@ -17,7 +17,6 @@ using Squidex.Domain.Apps.Events.Schemas; using Squidex.Infrastructure; using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.EventSourcing; -using Squidex.Infrastructure.Tasks; using Xunit; namespace Squidex.Domain.Apps.Entities.Contents @@ -87,7 +86,7 @@ namespace Squidex.Domain.Apps.Entities.Contents { rebuildContents.Add(id); - return TaskHelper.Done; + return Task.CompletedTask; }); A.CallTo(() => rebuilder.InsertManyAsync(A._, A._)) diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/ContentsSearchSourceTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/ContentsSearchSourceTests.cs index 535a86c46..ab816d538 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/ContentsSearchSourceTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/ContentsSearchSourceTests.cs @@ -30,7 +30,7 @@ namespace Squidex.Domain.Apps.Entities.Contents { private readonly IAppProvider appProvider = A.Fake(); private readonly IUrlGenerator urlGenerator = A.Fake(); - private readonly IContentTextIndex contentIndex = A.Fake(); + private readonly ITextIndex contentIndex = A.Fake(); private readonly IContentQueryService contentQuery = A.Fake(); private readonly NamedId appId = NamedId.Of(Guid.NewGuid(), "my-app"); private readonly NamedId schemaId1 = NamedId.Of(Guid.NewGuid(), "my-schema1"); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/MongoDb/ContentsQueryFixture.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/MongoDb/ContentsQueryFixture.cs index d25e9213b..6d58727a5 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/MongoDb/ContentsQueryFixture.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/MongoDb/ContentsQueryFixture.cs @@ -147,9 +147,9 @@ namespace Squidex.Domain.Apps.Entities.Contents.MongoDb return appProvider; } - private static IContentTextIndex CreateTextIndexer() + private static ITextIndex CreateTextIndexer() { - var textIndexer = A.Fake(); + var textIndexer = A.Fake(); A.CallTo(() => textIndexer.SearchAsync(A._, A._, A._, A._)) .Returns(new List { Guid.NewGuid() }); diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/MongoDb/ContentsQueryTests.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/MongoDb/ContentsQueryTests.cs index de0b8aafe..48bdb6981 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/MongoDb/ContentsQueryTests.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/MongoDb/ContentsQueryTests.cs @@ -12,7 +12,6 @@ using System.Threading.Tasks; using NodaTime; using Squidex.Infrastructure; using Squidex.Infrastructure.Queries; -using Squidex.Infrastructure.Tasks; using Xunit; using F = Squidex.Infrastructure.Queries.ClrFilter; @@ -75,7 +74,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.MongoDb { var time = SystemClock.Instance.GetCurrentInstant(); - await _.ContentRepository.QueryScheduledWithoutDataAsync(time, _ => TaskHelper.Done); + await _.ContentRepository.QueryScheduledWithoutDataAsync(time, _ => Task.CompletedTask); } [Fact] diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/IIndexerFactory.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/IIndexerFactory.cs index baa2e310f..c690164d8 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/IIndexerFactory.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/IIndexerFactory.cs @@ -12,7 +12,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text { public interface IIndexerFactory { - Task CreateAsync(Guid schemaId); + Task CreateAsync(Guid schemaId); Task CleanupAsync(); } diff --git a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/LuceneIndexFactory.cs b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/LuceneIndexFactory.cs index ba9c37c53..02cfa9ce4 100644 --- a/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/LuceneIndexFactory.cs +++ b/backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/LuceneIndexFactory.cs @@ -28,13 +28,15 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text .ReturnsLazily(() => grain); } - public async Task CreateAsync(Guid schemaId) + public async Task CreateAsync(Guid schemaId) { - grain = new LuceneTextIndexGrain(new IndexManager(storage, A.Fake())); + var indexManager = new IndexManager(storage, A.Fake()); + + grain = new LuceneTextIndexGrain(indexManager); await grain.ActivateAsync(schemaId); - return new LuceneTextIndex(grainFactory); + return new LuceneTextIndex(grainFactory, indexManager); } public async Task CleanupAsync() diff --git a/backend/tests/Squidex.Infrastructure.Tests/Commands/InMemoryCommandBusTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Commands/InMemoryCommandBusTests.cs index 3cfe87faf..82eb2d224 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Commands/InMemoryCommandBusTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Commands/InMemoryCommandBusTests.cs @@ -8,7 +8,6 @@ using System; using System.Threading.Tasks; using FakeItEasy; -using Squidex.Infrastructure.Tasks; using Xunit; namespace Squidex.Infrastructure.Commands @@ -27,7 +26,7 @@ namespace Squidex.Infrastructure.Commands context.Complete(true); - return TaskHelper.True; + return Task.FromResult(true); } } @@ -39,7 +38,7 @@ namespace Squidex.Infrastructure.Commands { LastCommand = context.Command; - return TaskHelper.Done; + return Task.CompletedTask; } } diff --git a/backend/tests/Squidex.Infrastructure.Tests/Commands/LogCommandMiddlewareTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Commands/LogCommandMiddlewareTests.cs index f2ef3d296..403256c19 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Commands/LogCommandMiddlewareTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Commands/LogCommandMiddlewareTests.cs @@ -10,7 +10,6 @@ using System.Collections.Generic; using System.Threading.Tasks; using FakeItEasy; using Squidex.Infrastructure.Log; -using Squidex.Infrastructure.Tasks; using Xunit; namespace Squidex.Infrastructure.Commands @@ -51,7 +50,7 @@ namespace Squidex.Infrastructure.Commands { context.Complete(true); - return TaskHelper.Done; + return Task.CompletedTask; }); Assert.Equal(log.LogLevels, new Dictionary @@ -84,7 +83,7 @@ namespace Squidex.Infrastructure.Commands { var context = new CommandContext(command, commandBus); - await sut.HandleAsync(context, c => TaskHelper.Done); + await sut.HandleAsync(context, c => Task.CompletedTask); Assert.Equal(log.LogLevels, new Dictionary { diff --git a/backend/tests/Squidex.Infrastructure.Tests/Commands/ReadonlyCommandMiddlewareTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Commands/ReadonlyCommandMiddlewareTests.cs index 5c4ed9e22..0262647e1 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Commands/ReadonlyCommandMiddlewareTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Commands/ReadonlyCommandMiddlewareTests.cs @@ -8,7 +8,6 @@ using System.Threading.Tasks; using FakeItEasy; using Microsoft.Extensions.Options; -using Squidex.Infrastructure.Tasks; using Xunit; namespace Squidex.Infrastructure.Commands @@ -55,7 +54,7 @@ namespace Squidex.Infrastructure.Commands { context.Complete(true); - return TaskHelper.Done; + return Task.CompletedTask; }); } } diff --git a/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/EventStoreTests.cs b/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/EventStoreTests.cs index 2cf1025d5..99839be34 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/EventStoreTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/EventSourcing/EventStoreTests.cs @@ -11,7 +11,6 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using FluentAssertions; -using Squidex.Infrastructure.Tasks; using Xunit; namespace Squidex.Infrastructure.EventSourcing @@ -38,7 +37,7 @@ namespace Squidex.Infrastructure.EventSourcing Events.Add(storedEvent); - return TaskHelper.Done; + return Task.CompletedTask; } } @@ -323,7 +322,7 @@ namespace Squidex.Infrastructure.EventSourcing { var readEvents = new List(); - await Sut.QueryAsync(x => { readEvents.Add(x); return TaskHelper.Done; }, property, value, null, cts.Token); + await Sut.QueryAsync(x => { readEvents.Add(x); return Task.CompletedTask; }, property, value, null, cts.Token); await Task.Delay(500, cts.Token); @@ -347,7 +346,7 @@ namespace Squidex.Infrastructure.EventSourcing { var readEvents = new List(); - await Sut.QueryAsync(x => { readEvents.Add(x); return TaskHelper.Done; }, streamFilter, position, cts.Token); + await Sut.QueryAsync(x => { readEvents.Add(x); return Task.CompletedTask; }, streamFilter, position, cts.Token); await Task.Delay(500, cts.Token); diff --git a/backend/tests/Squidex.Infrastructure.Tests/Migrations/MigratorTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Migrations/MigratorTests.cs index bf96f4a89..391577144 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Migrations/MigratorTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Migrations/MigratorTests.cs @@ -11,7 +11,6 @@ using System.Linq; using System.Threading.Tasks; using FakeItEasy; using Squidex.Infrastructure.Log; -using Squidex.Infrastructure.Tasks; using Xunit; namespace Squidex.Infrastructure.Migrations @@ -60,7 +59,7 @@ namespace Squidex.Infrastructure.Migrations version = newVersion; } - return TaskHelper.Done; + return Task.CompletedTask; } } diff --git a/backend/tests/Squidex.Infrastructure.Tests/MongoDb/MongoExtensionsTests.cs b/backend/tests/Squidex.Infrastructure.Tests/MongoDb/MongoExtensionsTests.cs index 030a6fbb7..ba28b028a 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/MongoDb/MongoExtensionsTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/MongoDb/MongoExtensionsTests.cs @@ -11,7 +11,6 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; using MongoDB.Driver; -using Squidex.Infrastructure.Tasks; using Xunit; namespace Squidex.Infrastructure.MongoDb @@ -82,7 +81,7 @@ namespace Squidex.Infrastructure.MongoDb await cursor.ForEachPipelineAsync(x => { result.Add(x); - return TaskHelper.Done; + return Task.CompletedTask; }); Assert.Equal(new List { 0, 1, 2, 3, 4, 5 }, result); @@ -102,7 +101,7 @@ namespace Squidex.Infrastructure.MongoDb return cursor.ForEachPipelineAsync(x => { result.Add(x); - return TaskHelper.Done; + return Task.CompletedTask; }); }); } @@ -129,7 +128,7 @@ namespace Squidex.Infrastructure.MongoDb } result.Add(x); - return TaskHelper.Done; + return Task.CompletedTask; }); }); } @@ -157,7 +156,7 @@ namespace Squidex.Infrastructure.MongoDb result.Add(x); - return TaskHelper.Done; + return Task.CompletedTask; }, cts.Token); }); } diff --git a/backend/tests/Squidex.Infrastructure.Tests/Tasks/SingleThreadedDispatcherTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Tasks/SingleThreadedDispatcherTests.cs index 63daefaa2..6b57dc5d3 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Tasks/SingleThreadedDispatcherTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Tasks/SingleThreadedDispatcherTests.cs @@ -28,7 +28,7 @@ namespace Squidex.Infrastructure.Tasks { target.Add(item); - return TaskHelper.Done; + return Task.CompletedTask; }).Forget(); } diff --git a/backend/tests/Squidex.Infrastructure.Tests/Timers/CompletionTimerTests.cs b/backend/tests/Squidex.Infrastructure.Tests/Timers/CompletionTimerTests.cs index cdce8c9b2..54831058f 100644 --- a/backend/tests/Squidex.Infrastructure.Tests/Timers/CompletionTimerTests.cs +++ b/backend/tests/Squidex.Infrastructure.Tests/Timers/CompletionTimerTests.cs @@ -5,7 +5,7 @@ // All rights reserved. Licensed under the MIT license. // ========================================================================== -using Squidex.Infrastructure.Tasks; +using System.Threading.Tasks; using Xunit; namespace Squidex.Infrastructure.Timers @@ -21,7 +21,7 @@ namespace Squidex.Infrastructure.Timers { called = true; - return TaskHelper.Done; + return Task.CompletedTask; }, 2000); timer.SkipCurrentDelay(); diff --git a/backend/tests/Squidex.Web.Tests/Pipeline/CleanupHostMiddlewareTests.cs b/backend/tests/Squidex.Web.Tests/Pipeline/CleanupHostMiddlewareTests.cs index be044be50..a7c81eb9a 100644 --- a/backend/tests/Squidex.Web.Tests/Pipeline/CleanupHostMiddlewareTests.cs +++ b/backend/tests/Squidex.Web.Tests/Pipeline/CleanupHostMiddlewareTests.cs @@ -7,7 +7,6 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Http; -using Squidex.Infrastructure.Tasks; using Xunit; #pragma warning disable RECS0092 // Convert field to readonly @@ -25,7 +24,7 @@ namespace Squidex.Web.Pipeline { isNextCalled = true; - return TaskHelper.Done; + return Task.CompletedTask; } sut = new CleanupHostMiddleware(Next); diff --git a/backend/tests/Squidex.Web.Tests/Pipeline/EnforceHttpsMiddlewareTests.cs b/backend/tests/Squidex.Web.Tests/Pipeline/EnforceHttpsMiddlewareTests.cs index c559125f8..7eca49342 100644 --- a/backend/tests/Squidex.Web.Tests/Pipeline/EnforceHttpsMiddlewareTests.cs +++ b/backend/tests/Squidex.Web.Tests/Pipeline/EnforceHttpsMiddlewareTests.cs @@ -7,7 +7,6 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.Http; -using Squidex.Infrastructure.Tasks; using Xunit; using Options = Microsoft.Extensions.Options.Options; @@ -26,7 +25,7 @@ namespace Squidex.Web.Pipeline { isNextCalled = true; - return TaskHelper.Done; + return Task.CompletedTask; }; sut = new EnforceHttpsMiddleware(Options.Create(options)); diff --git a/backend/tools/Migrate_01/Migrations/PopulateGrainIndexes.cs b/backend/tools/Migrate_01/Migrations/PopulateGrainIndexes.cs index 0af576fc7..19ec93f73 100644 --- a/backend/tools/Migrate_01/Migrations/PopulateGrainIndexes.cs +++ b/backend/tools/Migrate_01/Migrations/PopulateGrainIndexes.cs @@ -18,7 +18,6 @@ using Squidex.Domain.Apps.Events.Schemas; using Squidex.Infrastructure; using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.Migrations; -using Squidex.Infrastructure.Tasks; namespace Migrate_01.Migrations { @@ -109,7 +108,7 @@ namespace Migrate_01.Migrations break; } - return TaskHelper.Done; + return Task.CompletedTask; }, "^app\\-"); await indexApps.RebuildAsync(appsByName); @@ -143,7 +142,7 @@ namespace Migrate_01.Migrations break; } - return TaskHelper.Done; + return Task.CompletedTask; }, "^rule\\-"); foreach (var (appId, rules) in rulesByApp) @@ -175,7 +174,7 @@ namespace Migrate_01.Migrations break; } - return TaskHelper.Done; + return Task.CompletedTask; }, "^schema\\-"); foreach (var (appId, schemas) in schemasByApp)