Browse Source

* TaskHelper removed

* Cleanup in TextIndexers
* Use secondary read preference for contents.
pull/492/head
Sebastian 7 years ago
parent
commit
cf767e2dee
  1. 3
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/AllowedValuesValidator.cs
  2. 5
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/CollectionValidator.cs
  3. 3
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/PatternValidator.cs
  4. 3
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/RangeValidator.cs
  5. 5
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/RequiredStringValidator.cs
  6. 3
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/RequiredValidator.cs
  7. 3
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/StringLengthValidator.cs
  8. 3
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/UniqueValuesValidator.cs
  9. 2
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentCollectionAll.cs
  10. 10
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentCollectionPublished.cs
  11. 2
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentRepository.cs
  12. 3
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/OperationBase.cs
  13. 4
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/QueryContentsByQuery.cs
  14. 8
      backend/src/Squidex.Domain.Apps.Entities.MongoDb/FullText/MongoIndexStorage.cs
  15. 5
      backend/src/Squidex.Domain.Apps.Entities/Assets/AssetUsageTracker_EventHandling.cs
  16. 3
      backend/src/Squidex.Domain.Apps.Entities/Assets/BackupAssets.cs
  17. 3
      backend/src/Squidex.Domain.Apps.Entities/Assets/FileTagAssetMetadataSource.cs
  18. 3
      backend/src/Squidex.Domain.Apps.Entities/Assets/FileTypeAssetMetadataSource.cs
  19. 3
      backend/src/Squidex.Domain.Apps.Entities/Assets/RecursiveDeleter.cs
  20. 2
      backend/src/Squidex.Domain.Apps.Entities/Backup/BackupGrain.cs
  21. 3
      backend/src/Squidex.Domain.Apps.Entities/Backup/BackupWriter.cs
  22. 15
      backend/src/Squidex.Domain.Apps.Entities/Backup/IBackupHandler.cs
  23. 2
      backend/src/Squidex.Domain.Apps.Entities/Backup/RestoreGrain.cs
  24. 3
      backend/src/Squidex.Domain.Apps.Entities/Contents/BackupContents.cs
  25. 5
      backend/src/Squidex.Domain.Apps.Entities/Contents/ContentOperationContext.cs
  26. 5
      backend/src/Squidex.Domain.Apps.Entities/Contents/ContentSchedulerGrain.cs
  27. 4
      backend/src/Squidex.Domain.Apps.Entities/Contents/ContentsSearchSource.cs
  28. 3
      backend/src/Squidex.Domain.Apps.Entities/Contents/DefaultContentWorkflow.cs
  29. 3
      backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/IContentEnricherStep.cs
  30. 3
      backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/EnrichForCaching.cs
  31. 7
      backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Elastic/ElasticSearchTextIndex.cs
  32. 4
      backend/src/Squidex.Domain.Apps.Entities/Contents/Text/ITextIndex.cs
  33. 17
      backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Lucene/IndexManager.cs
  34. 13
      backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Lucene/LuceneTextIndex.cs
  35. 5
      backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Lucene/Storage/AssetIndexStorage.cs
  36. 5
      backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Lucene/Storage/FileIndexStorage.cs
  37. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Lucene/Storage/IIndexStorage.cs
  38. 7
      backend/src/Squidex.Domain.Apps.Entities/Contents/Text/State/InMemoryTextIndexerState.cs
  39. 13
      backend/src/Squidex.Domain.Apps.Entities/Contents/Text/TextIndexingProcess.cs
  40. 3
      backend/src/Squidex.Domain.Apps.Entities/History/Notifications/NoopNotificationEmailSender.cs
  41. 3
      backend/src/Squidex.Domain.Apps.Entities/History/Notifications/NotificationEmailEventConsumer.cs
  42. 3
      backend/src/Squidex.Domain.Apps.Entities/Rules/BackupRules.cs
  43. 6
      backend/src/Squidex.Domain.Apps.Entities/Rules/RuleDequeuerGrain.cs
  44. 3
      backend/src/Squidex.Domain.Apps.Entities/Rules/RuleEnqueuer.cs
  45. 7
      backend/src/Squidex.Domain.Apps.Entities/Rules/UsageTracking/UsageTrackerGrain.cs
  46. 3
      backend/src/Squidex.Domain.Apps.Entities/Schemas/BackupSchemas.cs
  47. 5
      backend/src/Squidex.Domain.Users.MongoDb/MongoRoleStore.cs
  48. 53
      backend/src/Squidex.Domain.Users.MongoDb/MongoUserStore.cs
  49. 4
      backend/src/Squidex.Domain.Users/DefaultXmlRepository.cs
  50. 7
      backend/src/Squidex.Infrastructure.Azure/EventSourcing/CosmosDbEventStore_Reader.cs
  51. 3
      backend/src/Squidex.Infrastructure.Azure/EventSourcing/CosmosDbSubscription.cs
  52. 3
      backend/src/Squidex.Infrastructure.GetEventStore/EventSourcing/GetEventStoreSubscription.cs
  53. 3
      backend/src/Squidex.Infrastructure.MongoDb/MongoDb/MongoRepositoryBase.cs
  54. 7
      backend/src/Squidex.Infrastructure.RabbitMq/CQRS/Events/RabbitMqEventConsumer.cs
  55. 7
      backend/src/Squidex.Infrastructure/Assets/FolderAssetStore.cs
  56. 2
      backend/src/Squidex.Infrastructure/Assets/MemoryAssetStore.cs
  57. 3
      backend/src/Squidex.Infrastructure/Commands/CommandExtensions.cs
  58. 2
      backend/src/Squidex.Infrastructure/Commands/DomainObjectBase.cs
  59. 10
      backend/src/Squidex.Infrastructure/EventSourcing/Grains/EventConsumerGrain.cs
  60. 3
      backend/src/Squidex.Infrastructure/LanguagesInitializer.cs
  61. 3
      backend/src/Squidex.Infrastructure/Log/Store/BackgroundRequestLogStore.cs
  62. 6
      backend/src/Squidex.Infrastructure/Orleans/ActivationLimit.cs
  63. 3
      backend/src/Squidex.Infrastructure/Orleans/GrainOfGuid.cs
  64. 5
      backend/src/Squidex.Infrastructure/Orleans/GrainOfString.cs
  65. 3
      backend/src/Squidex.Infrastructure/Orleans/Indexes/UniqueNameIndexGrain.cs
  66. 3
      backend/src/Squidex.Infrastructure/Orleans/LockGrain.cs
  67. 4
      backend/src/Squidex.Infrastructure/Tasks/SingleThreadedDispatcher.cs
  68. 2
      backend/src/Squidex.Infrastructure/Tasks/TaskExtensions.cs
  69. 27
      backend/src/Squidex.Infrastructure/Tasks/TaskHelper.cs
  70. 3
      backend/src/Squidex.Infrastructure/UsageTracking/BackgroundUsageTracker.cs
  71. 3
      backend/src/Squidex.Web/ApiPermissionAttribute.cs
  72. 3
      backend/src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs
  73. 3
      backend/src/Squidex/Config/Authentication/GoogleHandler.cs
  74. 2
      backend/src/Squidex/Config/Domain/ContentsServices.cs
  75. 3
      backend/src/Squidex/Config/Domain/SerializationInitializer.cs
  76. 3
      backend/src/Squidex/Config/Startup/LogConfigurationHost.cs
  77. 3
      backend/src/Squidex/Config/Startup/SafeHostedService.cs
  78. 5
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/BackupAssetsTests.cs
  79. 5
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Backup/BackupReaderWriterTests.cs
  80. 3
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Comments/CommentsCommandMiddlewareTests.cs
  81. 3
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/BackupContentsTests.cs
  82. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/ContentsSearchSourceTests.cs
  83. 4
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/MongoDb/ContentsQueryFixture.cs
  84. 3
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/MongoDb/ContentsQueryTests.cs
  85. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/IIndexerFactory.cs
  86. 8
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/LuceneIndexFactory.cs
  87. 5
      backend/tests/Squidex.Infrastructure.Tests/Commands/InMemoryCommandBusTests.cs
  88. 5
      backend/tests/Squidex.Infrastructure.Tests/Commands/LogCommandMiddlewareTests.cs
  89. 3
      backend/tests/Squidex.Infrastructure.Tests/Commands/ReadonlyCommandMiddlewareTests.cs
  90. 7
      backend/tests/Squidex.Infrastructure.Tests/EventSourcing/EventStoreTests.cs
  91. 3
      backend/tests/Squidex.Infrastructure.Tests/Migrations/MigratorTests.cs
  92. 9
      backend/tests/Squidex.Infrastructure.Tests/MongoDb/MongoExtensionsTests.cs
  93. 2
      backend/tests/Squidex.Infrastructure.Tests/Tasks/SingleThreadedDispatcherTests.cs
  94. 4
      backend/tests/Squidex.Infrastructure.Tests/Timers/CompletionTimerTests.cs
  95. 3
      backend/tests/Squidex.Web.Tests/Pipeline/CleanupHostMiddlewareTests.cs
  96. 3
      backend/tests/Squidex.Web.Tests/Pipeline/EnforceHttpsMiddlewareTests.cs
  97. 7
      backend/tools/Migrate_01/Migrations/PopulateGrainIndexes.cs

3
backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/AllowedValuesValidator.cs

@ -9,7 +9,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Core.ValidateContent.Validators 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."); addError(context.Path, "Not an allowed value.");
} }
return TaskHelper.Done; return Task.CompletedTask;
} }
} }
} }

5
backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/CollectionValidator.cs

@ -8,7 +8,6 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Core.ValidateContent.Validators namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
{ {
@ -39,7 +38,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
addError(context.Path, "Field is required."); addError(context.Path, "Field is required.");
} }
return TaskHelper.Done; return Task.CompletedTask;
} }
if (minItems.HasValue && maxItems.HasValue) if (minItems.HasValue && maxItems.HasValue)
@ -66,7 +65,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
} }
} }
return TaskHelper.Done; return Task.CompletedTask;
} }
} }
} }

3
backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/PatternValidator.cs

@ -8,7 +8,6 @@
using System; using System;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Core.ValidateContent.Validators namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
{ {
@ -52,7 +51,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
} }
} }
return TaskHelper.Done; return Task.CompletedTask;
} }
} }
} }

3
backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/RangeValidator.cs

@ -7,7 +7,6 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Core.ValidateContent.Validators namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
{ {
@ -56,7 +55,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
} }
} }
return TaskHelper.Done; return Task.CompletedTask;
} }
} }
} }

5
backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/RequiredStringValidator.cs

@ -6,7 +6,6 @@
// ========================================================================== // ==========================================================================
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Core.ValidateContent.Validators namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
{ {
@ -23,7 +22,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
{ {
if (context.IsOptional) if (context.IsOptional)
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
if (value.IsNullOrUndefined() || IsEmptyString(value)) if (value.IsNullOrUndefined() || IsEmptyString(value))
@ -31,7 +30,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
addError(context.Path, "Field is required."); addError(context.Path, "Field is required.");
} }
return TaskHelper.Done; return Task.CompletedTask;
} }
private bool IsEmptyString(object? value) private bool IsEmptyString(object? value)

3
backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/RequiredValidator.cs

@ -6,7 +6,6 @@
// ========================================================================== // ==========================================================================
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Core.ValidateContent.Validators namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
{ {
@ -19,7 +18,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
addError(context.Path, "Field is required."); addError(context.Path, "Field is required.");
} }
return TaskHelper.Done; return Task.CompletedTask;
} }
} }
} }

3
backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/StringLengthValidator.cs

@ -7,7 +7,6 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Core.ValidateContent.Validators namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
{ {
@ -56,7 +55,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
} }
} }
return TaskHelper.Done; return Task.CompletedTask;
} }
} }
} }

3
backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/UniqueValuesValidator.cs

@ -8,7 +8,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Core.ValidateContent.Validators namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
{ {
@ -26,7 +25,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
} }
} }
return TaskHelper.Done; return Task.CompletedTask;
} }
} }
} }

2
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 QueryIdsAsync queryIdsAsync;
private readonly QueryScheduledContents queryScheduledItems; 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) : base(database)
{ {
queryContentAsync = new QueryContent(serializer); queryContentAsync = new QueryContent(serializer);

10
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 QueryContentsByQuery queryContentsByQuery;
private readonly QueryIdsAsync queryIdsAsync; 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) : base(database)
{ {
queryContentAsync = new QueryContent(serializer); queryContentAsync = new QueryContent(serializer);
@ -45,6 +45,14 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents
return Collection; return Collection;
} }
protected override MongoCollectionSettings CollectionSettings()
{
return new MongoCollectionSettings
{
ReadPreference = ReadPreference.SecondaryPreferred.With(TimeSpan.FromSeconds(10))
};
}
protected override string CollectionName() protected override string CollectionName()
{ {
return "State_Contents_Published"; return "State_Contents_Published";

2
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/MongoContentRepository.cs

@ -34,7 +34,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents
StatusSerializer.Register(); 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(appProvider);
Guard.NotNull(serializer); Guard.NotNull(serializer);

3
backend/src/Squidex.Domain.Apps.Entities.MongoDb/Contents/Operations/OperationBase.cs

@ -9,7 +9,6 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MongoDB.Driver; using MongoDB.Driver;
using Squidex.Infrastructure.MongoDb; using Squidex.Infrastructure.MongoDb;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Entities.MongoDb.Contents.Operations 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) protected virtual Task PrepareAsync(CancellationToken ct = default)
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
} }
} }

4
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 internal sealed class QueryContentsByQuery : OperationBase
{ {
private readonly IJsonSerializer serializer; 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; this.serializer = serializer;

8
backend/src/Squidex.Domain.Apps.Entities.MongoDb/FullText/MongoIndexStorage.cs

@ -11,6 +11,7 @@ using System.Threading.Tasks;
using Lucene.Net.Index; using Lucene.Net.Index;
using MongoDB.Driver.GridFS; using MongoDB.Driver.GridFS;
using Squidex.Domain.Apps.Entities.Contents.Text.Lucene; using Squidex.Domain.Apps.Entities.Contents.Text.Lucene;
using Squidex.Infrastructure;
using LuceneDirectory = Lucene.Net.Store.Directory; using LuceneDirectory = Lucene.Net.Store.Directory;
namespace Squidex.Domain.Apps.Entities.MongoDb.FullText namespace Squidex.Domain.Apps.Entities.MongoDb.FullText
@ -21,6 +22,8 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.FullText
public MongoIndexStorage(IGridFSBucket<string> bucket) public MongoIndexStorage(IGridFSBucket<string> bucket)
{ {
Guard.NotNull(bucket);
this.bucket = bucket; this.bucket = bucket;
} }
@ -36,6 +39,11 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.FullText
return Task.FromResult<LuceneDirectory>(directory); return Task.FromResult<LuceneDirectory>(directory);
} }
public Task ClearAsync()
{
return bucket.DropAsync();
}
public Task WriteAsync(LuceneDirectory directory, SnapshotDeletionPolicy snapshotter) public Task WriteAsync(LuceneDirectory directory, SnapshotDeletionPolicy snapshotter)
{ {
return Task.CompletedTask; return Task.CompletedTask;

5
backend/src/Squidex.Domain.Apps.Entities/Assets/AssetUsageTracker_EventHandling.cs

@ -9,7 +9,6 @@ using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Domain.Apps.Events.Assets; using Squidex.Domain.Apps.Events.Assets;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Tasks;
using Squidex.Infrastructure.UsageTracking; using Squidex.Infrastructure.UsageTracking;
namespace Squidex.Domain.Apps.Entities.Assets namespace Squidex.Domain.Apps.Entities.Assets
@ -33,7 +32,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
public Task ClearAsync() public Task ClearAsync()
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task On(Envelope<IEvent> @event) public Task On(Envelope<IEvent> @event)
@ -50,7 +49,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
return UpdateSizeAsync(e.AppId.Id, GetDate(@event), e.DeletedSize, -1); return UpdateSizeAsync(e.AppId.Id, GetDate(@event), e.DeletedSize, -1);
} }
return TaskHelper.Done; return Task.CompletedTask;
} }
private static DateTime GetDate(Envelope<IEvent> @event) private static DateTime GetDate(Envelope<IEvent> @event)

3
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;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Entities.Assets 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 WriteAssetAsync(assetUpdated.AssetId, assetUpdated.FileVersion, context.Writer);
} }
return TaskHelper.Done; return Task.CompletedTask;
} }
public async Task<bool> RestoreEventAsync(Envelope<IEvent> @event, RestoreContext context) public async Task<bool> RestoreEventAsync(Envelope<IEvent> @event, RestoreContext context)

3
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;
using Squidex.Infrastructure.Assets; using Squidex.Infrastructure.Assets;
using Squidex.Infrastructure.Json.Objects; using Squidex.Infrastructure.Json.Objects;
using Squidex.Infrastructure.Tasks;
using TagLib; using TagLib;
using TagLib.Image; using TagLib.Image;
using static TagLib.File; using static TagLib.File;
@ -57,7 +56,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
{ {
Enhance(command); Enhance(command);
return TaskHelper.Done; return Task.CompletedTask;
} }
private void Enhance(UploadAssetCommand command) private void Enhance(UploadAssetCommand command)

3
backend/src/Squidex.Domain.Apps.Entities/Assets/FileTypeAssetMetadataSource.cs

@ -9,7 +9,6 @@ using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Domain.Apps.Entities.Assets.Commands; using Squidex.Domain.Apps.Entities.Assets.Commands;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Entities.Assets namespace Squidex.Domain.Apps.Entities.Assets
{ {
@ -27,7 +26,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
} }
} }
return TaskHelper.Done; return Task.CompletedTask;
} }
public IEnumerable<string> Format(IAssetEntity asset) public IEnumerable<string> Format(IAssetEntity asset)

3
backend/src/Squidex.Domain.Apps.Entities/Assets/RecursiveDeleter.cs

@ -15,7 +15,6 @@ using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Log; using Squidex.Infrastructure.Log;
using Squidex.Infrastructure.Reflection; using Squidex.Infrastructure.Reflection;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Entities.Assets namespace Squidex.Domain.Apps.Entities.Assets
{ {
@ -60,7 +59,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
public Task ClearAsync() public Task ClearAsync()
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
public bool Handles(StoredEvent @event) public bool Handles(StoredEvent @event)

2
backend/src/Squidex.Domain.Apps.Entities/Backup/BackupGrain.cs

@ -78,7 +78,7 @@ namespace Squidex.Domain.Apps.Entities.Backup
{ {
RecoverAfterRestartAsync().Forget(); RecoverAfterRestartAsync().Forget();
return TaskHelper.Done; return Task.CompletedTask;
} }
private async Task RecoverAfterRestartAsync() private async Task RecoverAfterRestartAsync()

3
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;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Json; using Squidex.Infrastructure.Json;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Entities.Backup namespace Squidex.Domain.Apps.Entities.Backup
{ {
@ -71,7 +70,7 @@ namespace Squidex.Domain.Apps.Entities.Backup
writtenAttachments++; writtenAttachments++;
return TaskHelper.Done; return Task.CompletedTask;
} }
public async Task WriteBlobAsync(string name, Func<Stream, Task> handler) public async Task WriteBlobAsync(string name, Func<Stream, Task> handler)

15
backend/src/Squidex.Domain.Apps.Entities/Backup/IBackupHandler.cs

@ -8,7 +8,6 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Entities.Backup namespace Squidex.Domain.Apps.Entities.Backup
{ {
@ -18,37 +17,37 @@ namespace Squidex.Domain.Apps.Entities.Backup
public Task<bool> RestoreEventAsync(Envelope<IEvent> @event, RestoreContext context) public Task<bool> RestoreEventAsync(Envelope<IEvent> @event, RestoreContext context)
{ {
return TaskHelper.True; return Task.FromResult(true);
} }
public Task BackupEventAsync(Envelope<IEvent> @event, BackupContext context) public Task BackupEventAsync(Envelope<IEvent> @event, BackupContext context)
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task RestoreAsync(RestoreContext context) public Task RestoreAsync(RestoreContext context)
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task BackupAsync(BackupContext context) public Task BackupAsync(BackupContext context)
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task CleanupRestoreErrorAsync(Guid appId) public Task CleanupRestoreErrorAsync(Guid appId)
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task CompleteRestoreAsync(RestoreContext context) public Task CompleteRestoreAsync(RestoreContext context)
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task CompleteBackupAsync(BackupContext context) public Task CompleteBackupAsync(BackupContext context)
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
} }
} }

2
backend/src/Squidex.Domain.Apps.Entities/Backup/RestoreGrain.cs

@ -85,7 +85,7 @@ namespace Squidex.Domain.Apps.Entities.Backup
{ {
RecoverAfterRestartAsync().Forget(); RecoverAfterRestartAsync().Forget();
return TaskHelper.Done; return Task.CompletedTask;
} }
private async Task RecoverAfterRestartAsync() private async Task RecoverAfterRestartAsync()

3
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;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Entities.Contents namespace Squidex.Domain.Apps.Entities.Contents
{ {
@ -46,7 +45,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
break; break;
} }
return TaskHelper.True; return Task.FromResult(true);
} }
public async Task RestoreAsync(RestoreContext context) public async Task RestoreAsync(RestoreContext context)

5
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.Contents.Repositories;
using Squidex.Domain.Apps.Entities.Schemas; using Squidex.Domain.Apps.Entities.Schemas;
using Squidex.Infrastructure.Queries; using Squidex.Infrastructure.Queries;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Entities.Contents namespace Squidex.Domain.Apps.Entities.Contents
{ {
@ -80,7 +79,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
{ {
data.GenerateDefaultValues(schemaEntity.SchemaDef, appEntity.PartitionResolver()); data.GenerateDefaultValues(schemaEntity.SchemaDef, appEntity.PartitionResolver());
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task ValidateAsync(NamedContentData data, bool optimized) public Task ValidateAsync(NamedContentData data, bool optimized)
@ -112,7 +111,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
scriptEngine.Execute(context, GetScript(script)); scriptEngine.Execute(context, GetScript(script));
return TaskHelper.Done; return Task.CompletedTask;
} }
private void Enrich(ScriptContext context) private void Enrich(ScriptContext context)

5
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;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Log; using Squidex.Infrastructure.Log;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Entities.Contents namespace Squidex.Domain.Apps.Entities.Contents
{ {
@ -61,7 +60,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
public Task ActivateAsync() public Task ActivateAsync()
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task PublishAsync() public Task PublishAsync()
@ -96,7 +95,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
public Task ReceiveReminder(string reminderName, TickStatus status) public Task ReceiveReminder(string reminderName, TickStatus status)
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
private Task Dispatch(Func<Task> task) private Task Dispatch(Func<Task> task)

4
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 IAppProvider appProvider;
private readonly IContentQueryService contentQuery; private readonly IContentQueryService contentQuery;
private readonly IContentTextIndex contentTextIndexer; private readonly ITextIndex contentTextIndexer;
private readonly IUrlGenerator urlGenerator; private readonly IUrlGenerator urlGenerator;
public ContentsSearchSource( public ContentsSearchSource(
IAppProvider appProvider, IAppProvider appProvider,
IContentQueryService contentQuery, IContentQueryService contentQuery,
IContentTextIndex contentTextIndexer, ITextIndex contentTextIndexer,
IUrlGenerator urlGenerator) IUrlGenerator urlGenerator)
{ {
Guard.NotNull(appProvider); Guard.NotNull(appProvider);

3
backend/src/Squidex.Domain.Apps.Entities/Contents/DefaultContentWorkflow.cs

@ -12,7 +12,6 @@ using System.Security.Claims;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Domain.Apps.Core.Contents; using Squidex.Domain.Apps.Core.Contents;
using Squidex.Domain.Apps.Entities.Schemas; using Squidex.Domain.Apps.Entities.Schemas;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Entities.Contents namespace Squidex.Domain.Apps.Entities.Contents
{ {
@ -55,7 +54,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
public Task<bool> CanPublishOnCreateAsync(ISchemaEntity schema, NamedContentData data, ClaimsPrincipal user) public Task<bool> CanPublishOnCreateAsync(ISchemaEntity schema, NamedContentData data, ClaimsPrincipal user)
{ {
return TaskHelper.True; return Task.FromResult(true);
} }
public Task<bool> CanMoveToAsync(IContentEntity content, Status status, Status next, ClaimsPrincipal user) public Task<bool> CanMoveToAsync(IContentEntity content, Status status, Status next, ClaimsPrincipal user)

3
backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/IContentEnricherStep.cs

@ -9,7 +9,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Domain.Apps.Entities.Schemas; using Squidex.Domain.Apps.Entities.Schemas;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Entities.Contents.Queries namespace Squidex.Domain.Apps.Entities.Contents.Queries
{ {
@ -21,7 +20,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries
Task EnrichAsync(Context context) Task EnrichAsync(Context context)
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
} }
} }

3
backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/Steps/EnrichForCaching.cs

@ -10,7 +10,6 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Caching; using Squidex.Infrastructure.Caching;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Entities.Contents.Queries.Steps namespace Squidex.Domain.Apps.Entities.Contents.Queries.Steps
{ {
@ -29,7 +28,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries.Steps
{ {
context.AddCacheHeaders(requestCache); context.AddCacheHeaders(requestCache);
return TaskHelper.Done; return Task.CompletedTask;
} }
public async Task EnrichAsync(Context context, IEnumerable<ContentEntity> contents, ProvideSchema schemas) public async Task EnrichAsync(Context context, IEnumerable<ContentEntity> contents, ProvideSchema schemas)

7
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 namespace Squidex.Domain.Apps.Entities.Contents.Text.Elastic
{ {
[ExcludeFromCodeCoverage] [ExcludeFromCodeCoverage]
public sealed class ElasticSearchTextIndex : IContentTextIndex public sealed class ElasticSearchTextIndex : ITextIndex
{ {
private const string IndexName = "contents"; private const string IndexName = "contents";
private readonly ElasticLowLevelClient client; private readonly ElasticLowLevelClient client;
@ -28,6 +28,11 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.Elastic
client = new ElasticLowLevelClient(config); client = new ElasticLowLevelClient(config);
} }
public Task ClearAsync()
{
return Task.CompletedTask;
}
public async Task ExecuteAsync(NamedId<Guid> appId, NamedId<Guid> schemaId, params IndexCommand[] commands) public async Task ExecuteAsync(NamedId<Guid> appId, NamedId<Guid> schemaId, params IndexCommand[] commands)
{ {
foreach (var command in commands) foreach (var command in commands)

4
backend/src/Squidex.Domain.Apps.Entities/Contents/Text/IContentTextIndex.cs → backend/src/Squidex.Domain.Apps.Entities/Contents/Text/ITextIndex.cs

@ -13,10 +13,12 @@ using Squidex.Infrastructure;
namespace Squidex.Domain.Apps.Entities.Contents.Text namespace Squidex.Domain.Apps.Entities.Contents.Text
{ {
public interface IContentTextIndex public interface ITextIndex
{ {
Task<List<Guid>?> SearchAsync(string? queryText, IAppEntity app, SearchFilter? filter, SearchScope scope); Task<List<Guid>?> SearchAsync(string? queryText, IAppEntity app, SearchFilter? filter, SearchScope scope);
Task ClearAsync();
Task ExecuteAsync(NamedId<Guid> appId, NamedId<Guid> schemaId, params IndexCommand[] commands); Task ExecuteAsync(NamedId<Guid> appId, NamedId<Guid> schemaId, params IndexCommand[] commands);
} }
} }

17
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<Guid, IndexHolder> indices = new Dictionary<Guid, IndexHolder>(); private readonly Dictionary<Guid, IndexHolder> indices = new Dictionary<Guid, IndexHolder>();
private readonly SemaphoreSlim lockObject = new SemaphoreSlim(1); private readonly SemaphoreSlim lockObject = new SemaphoreSlim(1);
private readonly IIndexStorage directoryFactory; private readonly IIndexStorage indexStorage;
private readonly ISemanticLog log; 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); Guard.NotNull(log);
this.directoryFactory = directoryFactory; this.indexStorage = indexStorage;
this.log = log; this.log = log;
} }
@ -40,6 +40,11 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.Lucene
} }
} }
public Task ClearAsync()
{
return indexStorage.ClearAsync();
}
public async Task<IIndex> AcquireAsync(Guid schemaId) public async Task<IIndex> AcquireAsync(Guid schemaId)
{ {
IndexHolder? indexHolder; IndexHolder? indexHolder;
@ -65,7 +70,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.Lucene
lockObject.Release(); lockObject.Release();
} }
var directory = await directoryFactory.CreateDirectoryAsync(schemaId); var directory = await indexStorage.CreateDirectoryAsync(schemaId);
indexHolder.Open(directory); indexHolder.Open(directory);
@ -113,7 +118,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.Lucene
holder.Commit(); holder.Commit();
} }
await directoryFactory.WriteAsync(holder.GetUnsafeWriter().Directory, holder.Snapshotter); await indexStorage.WriteAsync(holder.GetUnsafeWriter().Directory, holder.Snapshotter);
} }
} }

13
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 namespace Squidex.Domain.Apps.Entities.Contents.Text.Lucene
{ {
public sealed class LuceneTextIndex : IContentTextIndex public sealed class LuceneTextIndex : ITextIndex
{ {
private readonly IGrainFactory grainFactory; private readonly IGrainFactory grainFactory;
private readonly IndexManager indexManager;
public LuceneTextIndex(IGrainFactory grainFactory) public LuceneTextIndex(IGrainFactory grainFactory, IndexManager indexManager)
{ {
Guard.NotNull(grainFactory); Guard.NotNull(grainFactory);
Guard.NotNull(indexManager);
this.grainFactory = grainFactory; this.grainFactory = grainFactory;
this.indexManager = indexManager;
}
public Task ClearAsync()
{
return indexManager.ClearAsync();
} }
public async Task<List<Guid>?> SearchAsync(string? queryText, IAppEntity app, SearchFilter? filter, SearchScope scope) public async Task<List<Guid>?> SearchAsync(string? queryText, IAppEntity app, SearchFilter? filter, SearchScope scope)

5
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; return directory;
} }
public Task ClearAsync()
{
return Task.CompletedTask;
}
public async Task WriteAsync(LuceneDirectory directory, SnapshotDeletionPolicy snapshotter) public async Task WriteAsync(LuceneDirectory directory, SnapshotDeletionPolicy snapshotter)
{ {
Guard.NotNull(directory); Guard.NotNull(directory);

5
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<LuceneDirectory>(FSDirectory.Open(folderPath)); return Task.FromResult<LuceneDirectory>(FSDirectory.Open(folderPath));
} }
public Task ClearAsync()
{
return Task.CompletedTask;
}
public Task WriteAsync(LuceneDirectory directory, SnapshotDeletionPolicy snapshotter) public Task WriteAsync(LuceneDirectory directory, SnapshotDeletionPolicy snapshotter)
{ {
return Task.CompletedTask; return Task.CompletedTask;

2
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<Directory> CreateDirectoryAsync(Guid schemaId); Task<Directory> CreateDirectoryAsync(Guid schemaId);
Task ClearAsync();
Task WriteAsync(Directory directory, SnapshotDeletionPolicy snapshotter); Task WriteAsync(Directory directory, SnapshotDeletionPolicy snapshotter);
} }
} }

7
backend/src/Squidex.Domain.Apps.Entities/Contents/Text/State/InMemoryTextIndexerState.cs

@ -8,7 +8,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Entities.Contents.Text.State namespace Squidex.Domain.Apps.Entities.Contents.Text.State
{ {
@ -20,7 +19,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.State
{ {
states.Clear(); states.Clear();
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task<TextContentState?> GetAsync(Guid contentId) public Task<TextContentState?> GetAsync(Guid contentId)
@ -37,14 +36,14 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.State
{ {
states.Remove(contentId); states.Remove(contentId);
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task SetAsync(TextContentState state) public Task SetAsync(TextContentState state)
{ {
states[state.ContentId] = state; states[state.ContentId] = state;
return TaskHelper.Done; return Task.CompletedTask;
} }
} }
} }

13
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 public sealed class TextIndexingProcess : IEventConsumer
{ {
private const string NotFound = "<404>"; private const string NotFound = "<404>";
private readonly IContentTextIndex textIndexer; private readonly ITextIndex textIndexer;
private readonly ITextIndexerState textIndexerState; private readonly ITextIndexerState textIndexerState;
public string Name public string Name
{ {
get { return "TextIndexer2"; } get { return "TextIndexer3"; }
} }
public string EventsFilter public string EventsFilter
@ -30,12 +30,12 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text
get { return "^content-"; } get { return "^content-"; }
} }
public IContentTextIndex TextIndexer public ITextIndex TextIndexer
{ {
get { return textIndexer; } get { return textIndexer; }
} }
public TextIndexingProcess(IContentTextIndex textIndexer, ITextIndexerState textIndexerState) public TextIndexingProcess(ITextIndex textIndexer, ITextIndexerState textIndexerState)
{ {
Guard.NotNull(textIndexer); Guard.NotNull(textIndexer);
Guard.NotNull(textIndexerState); Guard.NotNull(textIndexerState);
@ -49,9 +49,10 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text
return true; return true;
} }
public Task ClearAsync() public async Task ClearAsync()
{ {
return textIndexerState.ClearAsync(); await textIndexer.ClearAsync();
await textIndexerState.ClearAsync();
} }
public async Task On(Envelope<IEvent> @event) public async Task On(Envelope<IEvent> @event)

3
backend/src/Squidex.Domain.Apps.Entities/History/Notifications/NoopNotificationEmailSender.cs

@ -6,7 +6,6 @@
// ========================================================================== // ==========================================================================
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Infrastructure.Tasks;
using Squidex.Shared.Users; using Squidex.Shared.Users;
namespace Squidex.Domain.Apps.Entities.History.Notifications 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) public Task SendContributorEmailAsync(IUser assigner, IUser assignee, string appName, bool isCreated)
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
} }
} }

3
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;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Log; using Squidex.Infrastructure.Log;
using Squidex.Infrastructure.Tasks;
using Squidex.Shared.Users; using Squidex.Shared.Users;
namespace Squidex.Domain.Apps.Entities.History.Notifications namespace Squidex.Domain.Apps.Entities.History.Notifications
@ -52,7 +51,7 @@ namespace Squidex.Domain.Apps.Entities.History.Notifications
public Task ClearAsync() public Task ClearAsync()
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
public async Task On(Envelope<IEvent> @event) public async Task On(Envelope<IEvent> @event)

3
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.Domain.Apps.Events.Rules;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Entities.Rules namespace Squidex.Domain.Apps.Entities.Rules
{ {
@ -43,7 +42,7 @@ namespace Squidex.Domain.Apps.Entities.Rules
break; break;
} }
return TaskHelper.True; return Task.FromResult(true);
} }
public Task RestoreAsync(RestoreContext context) public Task RestoreAsync(RestoreContext context)

6
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)); RegisterOrUpdateReminder("Default", TimeSpan.Zero, TimeSpan.FromMinutes(10));
RegisterTimer(x => QueryAsync(), null, TimeSpan.Zero, TimeSpan.FromSeconds(10)); RegisterTimer(x => QueryAsync(), null, TimeSpan.Zero, TimeSpan.FromSeconds(10));
return TaskHelper.Done; return Task.CompletedTask;
} }
public override Task OnDeactivateAsync() public override Task OnDeactivateAsync()
@ -68,7 +68,7 @@ namespace Squidex.Domain.Apps.Entities.Rules
public Task ActivateAsync() public Task ActivateAsync()
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
public async Task QueryAsync() public async Task QueryAsync()
@ -157,7 +157,7 @@ namespace Squidex.Domain.Apps.Entities.Rules
public Task ReceiveReminder(string reminderName, TickStatus status) public Task ReceiveReminder(string reminderName, TickStatus status)
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
} }
} }

3
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.Domain.Apps.Events;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Entities.Rules namespace Squidex.Domain.Apps.Entities.Rules
{ {
@ -60,7 +59,7 @@ namespace Squidex.Domain.Apps.Entities.Rules
public Task ClearAsync() public Task ClearAsync()
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
public async Task Enqueue(Rule rule, Guid ruleId, Envelope<IEvent> @event) public async Task Enqueue(Rule rule, Guid ruleId, Envelope<IEvent> @event)

7
backend/src/Squidex.Domain.Apps.Entities/Rules/UsageTracking/UsageTrackerGrain.cs

@ -16,7 +16,6 @@ using Squidex.Infrastructure;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Orleans; using Squidex.Infrastructure.Orleans;
using Squidex.Infrastructure.States; using Squidex.Infrastructure.States;
using Squidex.Infrastructure.Tasks;
using Squidex.Infrastructure.UsageTracking; using Squidex.Infrastructure.UsageTracking;
namespace Squidex.Domain.Apps.Entities.Rules.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)); RegisterOrUpdateReminder("Default", TimeSpan.Zero, TimeSpan.FromMinutes(10));
RegisterTimer(x => CheckUsagesAsync(), null, TimeSpan.Zero, TimeSpan.FromMinutes(10)); RegisterTimer(x => CheckUsagesAsync(), null, TimeSpan.Zero, TimeSpan.FromMinutes(10));
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task ActivateAsync() public Task ActivateAsync()
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task ReceiveReminder(string reminderName, TickStatus status) public Task ReceiveReminder(string reminderName, TickStatus status)
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
public async Task CheckUsagesAsync() public async Task CheckUsagesAsync()

3
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.Domain.Apps.Events.Schemas;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Entities.Schemas namespace Squidex.Domain.Apps.Entities.Schemas
{ {
@ -43,7 +42,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas
break; break;
} }
return TaskHelper.True; return Task.FromResult(true);
} }
public Task RestoreAsync(RestoreContext context) public Task RestoreAsync(RestoreContext context)

5
backend/src/Squidex.Domain.Users.MongoDb/MongoRoleStore.cs

@ -13,7 +13,6 @@ using MongoDB.Bson.Serialization;
using MongoDB.Bson.Serialization.Serializers; using MongoDB.Bson.Serialization.Serializers;
using MongoDB.Driver; using MongoDB.Driver;
using Squidex.Infrastructure.MongoDb; using Squidex.Infrastructure.MongoDb;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Users.MongoDb namespace Squidex.Domain.Users.MongoDb
{ {
@ -119,14 +118,14 @@ namespace Squidex.Domain.Users.MongoDb
{ {
role.Name = roleName; role.Name = roleName;
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task SetNormalizedRoleNameAsync(IdentityRole role, string normalizedName, CancellationToken cancellationToken) public Task SetNormalizedRoleNameAsync(IdentityRole role, string normalizedName, CancellationToken cancellationToken)
{ {
role.NormalizedName = normalizedName; role.NormalizedName = normalizedName;
return TaskHelper.Done; return Task.CompletedTask;
} }
} }
} }

53
backend/src/Squidex.Domain.Users.MongoDb/MongoUserStore.cs

@ -17,7 +17,6 @@ using MongoDB.Bson.Serialization;
using MongoDB.Bson.Serialization.Serializers; using MongoDB.Bson.Serialization.Serializers;
using MongoDB.Driver; using MongoDB.Driver;
using Squidex.Infrastructure.MongoDb; using Squidex.Infrastructure.MongoDb;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Users.MongoDb namespace Squidex.Domain.Users.MongoDb
{ {
@ -354,126 +353,126 @@ namespace Squidex.Domain.Users.MongoDb
{ {
((MongoUser)user).UserName = userName; ((MongoUser)user).UserName = userName;
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task SetNormalizedUserNameAsync(IdentityUser user, string normalizedName, CancellationToken cancellationToken) public Task SetNormalizedUserNameAsync(IdentityUser user, string normalizedName, CancellationToken cancellationToken)
{ {
((MongoUser)user).NormalizedUserName = normalizedName; ((MongoUser)user).NormalizedUserName = normalizedName;
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task SetPasswordHashAsync(IdentityUser user, string passwordHash, CancellationToken cancellationToken) public Task SetPasswordHashAsync(IdentityUser user, string passwordHash, CancellationToken cancellationToken)
{ {
((MongoUser)user).PasswordHash = passwordHash; ((MongoUser)user).PasswordHash = passwordHash;
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task AddToRoleAsync(IdentityUser user, string roleName, CancellationToken cancellationToken) public Task AddToRoleAsync(IdentityUser user, string roleName, CancellationToken cancellationToken)
{ {
((MongoUser)user).AddRole(roleName); ((MongoUser)user).AddRole(roleName);
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task RemoveFromRoleAsync(IdentityUser user, string roleName, CancellationToken cancellationToken) public Task RemoveFromRoleAsync(IdentityUser user, string roleName, CancellationToken cancellationToken)
{ {
((MongoUser)user).RemoveRole(roleName); ((MongoUser)user).RemoveRole(roleName);
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task AddLoginAsync(IdentityUser user, UserLoginInfo login, CancellationToken cancellationToken) public Task AddLoginAsync(IdentityUser user, UserLoginInfo login, CancellationToken cancellationToken)
{ {
((MongoUser)user).AddLogin(login); ((MongoUser)user).AddLogin(login);
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task RemoveLoginAsync(IdentityUser user, string loginProvider, string providerKey, CancellationToken cancellationToken) public Task RemoveLoginAsync(IdentityUser user, string loginProvider, string providerKey, CancellationToken cancellationToken)
{ {
((MongoUser)user).RemoveLogin(loginProvider, providerKey); ((MongoUser)user).RemoveLogin(loginProvider, providerKey);
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task SetSecurityStampAsync(IdentityUser user, string stamp, CancellationToken cancellationToken) public Task SetSecurityStampAsync(IdentityUser user, string stamp, CancellationToken cancellationToken)
{ {
((MongoUser)user).SecurityStamp = stamp; ((MongoUser)user).SecurityStamp = stamp;
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task SetEmailAsync(IdentityUser user, string email, CancellationToken cancellationToken) public Task SetEmailAsync(IdentityUser user, string email, CancellationToken cancellationToken)
{ {
((MongoUser)user).Email = email; ((MongoUser)user).Email = email;
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task SetEmailConfirmedAsync(IdentityUser user, bool confirmed, CancellationToken cancellationToken) public Task SetEmailConfirmedAsync(IdentityUser user, bool confirmed, CancellationToken cancellationToken)
{ {
((MongoUser)user).EmailConfirmed = confirmed; ((MongoUser)user).EmailConfirmed = confirmed;
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task SetNormalizedEmailAsync(IdentityUser user, string normalizedEmail, CancellationToken cancellationToken) public Task SetNormalizedEmailAsync(IdentityUser user, string normalizedEmail, CancellationToken cancellationToken)
{ {
((MongoUser)user).NormalizedEmail = normalizedEmail; ((MongoUser)user).NormalizedEmail = normalizedEmail;
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task AddClaimsAsync(IdentityUser user, IEnumerable<Claim> claims, CancellationToken cancellationToken) public Task AddClaimsAsync(IdentityUser user, IEnumerable<Claim> claims, CancellationToken cancellationToken)
{ {
((MongoUser)user).AddClaims(claims); ((MongoUser)user).AddClaims(claims);
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task ReplaceClaimAsync(IdentityUser user, Claim claim, Claim newClaim, CancellationToken cancellationToken) public Task ReplaceClaimAsync(IdentityUser user, Claim claim, Claim newClaim, CancellationToken cancellationToken)
{ {
((MongoUser)user).ReplaceClaim(claim, newClaim); ((MongoUser)user).ReplaceClaim(claim, newClaim);
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task RemoveClaimsAsync(IdentityUser user, IEnumerable<Claim> claims, CancellationToken cancellationToken) public Task RemoveClaimsAsync(IdentityUser user, IEnumerable<Claim> claims, CancellationToken cancellationToken)
{ {
((MongoUser)user).RemoveClaims(claims); ((MongoUser)user).RemoveClaims(claims);
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task SetPhoneNumberAsync(IdentityUser user, string phoneNumber, CancellationToken cancellationToken) public Task SetPhoneNumberAsync(IdentityUser user, string phoneNumber, CancellationToken cancellationToken)
{ {
((MongoUser)user).PhoneNumber = phoneNumber; ((MongoUser)user).PhoneNumber = phoneNumber;
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task SetPhoneNumberConfirmedAsync(IdentityUser user, bool confirmed, CancellationToken cancellationToken) public Task SetPhoneNumberConfirmedAsync(IdentityUser user, bool confirmed, CancellationToken cancellationToken)
{ {
((MongoUser)user).PhoneNumberConfirmed = confirmed; ((MongoUser)user).PhoneNumberConfirmed = confirmed;
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task SetTwoFactorEnabledAsync(IdentityUser user, bool enabled, CancellationToken cancellationToken) public Task SetTwoFactorEnabledAsync(IdentityUser user, bool enabled, CancellationToken cancellationToken)
{ {
((MongoUser)user).TwoFactorEnabled = enabled; ((MongoUser)user).TwoFactorEnabled = enabled;
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task SetLockoutEndDateAsync(IdentityUser user, DateTimeOffset? lockoutEnd, CancellationToken cancellationToken) public Task SetLockoutEndDateAsync(IdentityUser user, DateTimeOffset? lockoutEnd, CancellationToken cancellationToken)
{ {
((MongoUser)user).LockoutEnd = lockoutEnd?.UtcDateTime; ((MongoUser)user).LockoutEnd = lockoutEnd?.UtcDateTime;
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task<int> IncrementAccessFailedCountAsync(IdentityUser user, CancellationToken cancellationToken) public Task<int> IncrementAccessFailedCountAsync(IdentityUser user, CancellationToken cancellationToken)
@ -487,42 +486,42 @@ namespace Squidex.Domain.Users.MongoDb
{ {
((MongoUser)user).AccessFailedCount = 0; ((MongoUser)user).AccessFailedCount = 0;
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task SetLockoutEnabledAsync(IdentityUser user, bool enabled, CancellationToken cancellationToken) public Task SetLockoutEnabledAsync(IdentityUser user, bool enabled, CancellationToken cancellationToken)
{ {
((MongoUser)user).LockoutEnabled = enabled; ((MongoUser)user).LockoutEnabled = enabled;
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task SetTokenAsync(IdentityUser user, string loginProvider, string name, string value, CancellationToken cancellationToken) public Task SetTokenAsync(IdentityUser user, string loginProvider, string name, string value, CancellationToken cancellationToken)
{ {
((MongoUser)user).SetToken(loginProvider, name, value); ((MongoUser)user).SetToken(loginProvider, name, value);
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task RemoveTokenAsync(IdentityUser user, string loginProvider, string name, CancellationToken cancellationToken) public Task RemoveTokenAsync(IdentityUser user, string loginProvider, string name, CancellationToken cancellationToken)
{ {
((MongoUser)user).RemoveToken(loginProvider, name); ((MongoUser)user).RemoveToken(loginProvider, name);
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task SetAuthenticatorKeyAsync(IdentityUser user, string key, CancellationToken cancellationToken) public Task SetAuthenticatorKeyAsync(IdentityUser user, string key, CancellationToken cancellationToken)
{ {
((MongoUser)user).SetToken(InternalLoginProvider, AuthenticatorKeyTokenName, key); ((MongoUser)user).SetToken(InternalLoginProvider, AuthenticatorKeyTokenName, key);
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task ReplaceCodesAsync(IdentityUser user, IEnumerable<string> recoveryCodes, CancellationToken cancellationToken) public Task ReplaceCodesAsync(IdentityUser user, IEnumerable<string> recoveryCodes, CancellationToken cancellationToken)
{ {
((MongoUser)user).SetToken(InternalLoginProvider, RecoveryCodeTokenName, string.Join(";", recoveryCodes)); ((MongoUser)user).SetToken(InternalLoginProvider, RecoveryCodeTokenName, string.Join(";", recoveryCodes));
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task<bool> RedeemCodeAsync(IdentityUser user, string code, CancellationToken cancellationToken) public Task<bool> RedeemCodeAsync(IdentityUser user, string code, CancellationToken cancellationToken)
@ -536,10 +535,10 @@ namespace Squidex.Domain.Users.MongoDb
((MongoUser)user).SetToken(InternalLoginProvider, RecoveryCodeTokenName, string.Join(";", updatedCodes)); ((MongoUser)user).SetToken(InternalLoginProvider, RecoveryCodeTokenName, string.Join(";", updatedCodes));
return TaskHelper.True; return Task.FromResult(true);
} }
return TaskHelper.False; return Task.FromResult(false);
} }
} }
} }

4
backend/src/Squidex.Domain.Users/DefaultXmlRepository.cs

@ -6,11 +6,11 @@
// ========================================================================== // ==========================================================================
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks;
using System.Xml.Linq; using System.Xml.Linq;
using Microsoft.AspNetCore.DataProtection.Repositories; using Microsoft.AspNetCore.DataProtection.Repositories;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.States; using Squidex.Infrastructure.States;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Users namespace Squidex.Domain.Users
{ {
@ -39,7 +39,7 @@ namespace Squidex.Domain.Users
{ {
result.Add(XElement.Parse(state.Xml)); result.Add(XElement.Parse(state.Xml));
return TaskHelper.Done; return Task.CompletedTask;
}).Wait(); }).Wait();
return result; return result;

7
backend/src/Squidex.Infrastructure.Azure/EventSourcing/CosmosDbEventStore_Reader.cs

@ -12,7 +12,6 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Azure.Documents; using Microsoft.Azure.Documents;
using Squidex.Infrastructure.Log; using Squidex.Infrastructure.Log;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Infrastructure.EventSourcing namespace Squidex.Infrastructure.EventSourcing
{ {
@ -37,7 +36,7 @@ namespace Squidex.Infrastructure.EventSourcing
ThrowIfDisposed(); ThrowIfDisposed();
return TaskHelper.Done; return Task.CompletedTask;
} }
public async Task<IReadOnlyList<StoredEvent>> QueryLatestAsync(string streamName, int count) public async Task<IReadOnlyList<StoredEvent>> QueryLatestAsync(string streamName, int count)
@ -74,7 +73,7 @@ namespace Squidex.Infrastructure.EventSourcing
result.Add(new StoredEvent(streamName, eventToken, eventStreamOffset, eventData)); result.Add(new StoredEvent(streamName, eventToken, eventStreamOffset, eventData));
} }
return TaskHelper.Done; return Task.CompletedTask;
}); });
IEnumerable<StoredEvent> ordered = result.OrderBy(x => x.EventStreamNumber); IEnumerable<StoredEvent> ordered = result.OrderBy(x => x.EventStreamNumber);
@ -120,7 +119,7 @@ namespace Squidex.Infrastructure.EventSourcing
} }
} }
return TaskHelper.Done; return Task.CompletedTask;
}); });
return result; return result;

3
backend/src/Squidex.Infrastructure.Azure/EventSourcing/CosmosDbSubscription.cs

@ -13,7 +13,6 @@ using System.Threading.Tasks;
using Microsoft.Azure.Documents; using Microsoft.Azure.Documents;
using Microsoft.Azure.Documents.ChangeFeedProcessor.FeedProcessing; using Microsoft.Azure.Documents.ChangeFeedProcessor.FeedProcessing;
using Newtonsoft.Json; using Newtonsoft.Json;
using Squidex.Infrastructure.Tasks;
using Builder = Microsoft.Azure.Documents.ChangeFeedProcessor.ChangeFeedProcessorBuilder; using Builder = Microsoft.Azure.Documents.ChangeFeedProcessor.ChangeFeedProcessorBuilder;
using Collection = Microsoft.Azure.Documents.ChangeFeedProcessor.DocumentCollectionInfo; using Collection = Microsoft.Azure.Documents.ChangeFeedProcessor.DocumentCollectionInfo;
using Options = Microsoft.Azure.Documents.ChangeFeedProcessor.ChangeFeedProcessorOptions; using Options = Microsoft.Azure.Documents.ChangeFeedProcessor.ChangeFeedProcessorOptions;
@ -104,7 +103,7 @@ namespace Squidex.Infrastructure.EventSourcing
public Task OpenAsync(IChangeFeedObserverContext context) public Task OpenAsync(IChangeFeedObserverContext context)
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
public async Task ProcessChangesAsync(IChangeFeedObserverContext context, IReadOnlyList<Document> docs, CancellationToken cancellationToken) public async Task ProcessChangesAsync(IChangeFeedObserverContext context, IReadOnlyList<Document> docs, CancellationToken cancellationToken)

3
backend/src/Squidex.Infrastructure.GetEventStore/EventSourcing/GetEventStoreSubscription.cs

@ -9,7 +9,6 @@ using System.Threading.Tasks;
using EventStore.ClientAPI; using EventStore.ClientAPI;
using EventStore.ClientAPI.Exceptions; using EventStore.ClientAPI.Exceptions;
using Squidex.Infrastructure.Json; using Squidex.Infrastructure.Json;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Infrastructure.EventSourcing namespace Squidex.Infrastructure.EventSourcing
{ {
@ -48,7 +47,7 @@ namespace Squidex.Infrastructure.EventSourcing
{ {
subscription.Stop(); subscription.Stop();
return TaskHelper.Done; return Task.CompletedTask;
} }
public void WakeUp() public void WakeUp()

3
backend/src/Squidex.Infrastructure.MongoDb/MongoDb/MongoRepositoryBase.cs

@ -10,7 +10,6 @@ using System.Globalization;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MongoDB.Driver; using MongoDB.Driver;
using Squidex.Infrastructure.Tasks;
#pragma warning disable RECS0108 // Warns about static fields in generic types #pragma warning disable RECS0108 // Warns about static fields in generic types
@ -81,7 +80,7 @@ namespace Squidex.Infrastructure.MongoDb
protected virtual Task SetupCollectionAsync(IMongoCollection<TEntity> collection, CancellationToken ct = default) protected virtual Task SetupCollectionAsync(IMongoCollection<TEntity> collection, CancellationToken ct = default)
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
public virtual async Task ClearAsync() public virtual async Task ClearAsync()

7
backend/src/Squidex.Infrastructure.RabbitMq/CQRS/Events/RabbitMqEventConsumer.cs

@ -12,7 +12,6 @@ using System.Threading.Tasks;
using RabbitMQ.Client; using RabbitMQ.Client;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Json; using Squidex.Infrastructure.Json;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Infrastructure.CQRS.Events 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}"); throw new ConfigurationException($"RabbitMq event bus failed to connect to {connectionFactory.Endpoint}");
} }
return TaskHelper.Done; return Task.CompletedTask;
} }
catch (Exception e) catch (Exception e)
{ {
@ -88,7 +87,7 @@ namespace Squidex.Infrastructure.CQRS.Events
public Task ClearAsync() public Task ClearAsync()
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task On(Envelope<IEvent> @event) public Task On(Envelope<IEvent> @event)
@ -98,7 +97,7 @@ namespace Squidex.Infrastructure.CQRS.Events
channel.Value.BasicPublish(exchange, string.Empty, null, jsonBytes); channel.Value.BasicPublish(exchange, string.Empty, null, jsonBytes);
return TaskHelper.Done; return Task.CompletedTask;
} }
} }
} }

7
backend/src/Squidex.Infrastructure/Assets/FolderAssetStore.cs

@ -10,7 +10,6 @@ using System.IO;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Infrastructure.Log; using Squidex.Infrastructure.Log;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Infrastructure.Assets namespace Squidex.Infrastructure.Assets
{ {
@ -43,7 +42,7 @@ namespace Squidex.Infrastructure.Assets
.WriteProperty("action", "FolderAssetStoreConfigured") .WriteProperty("action", "FolderAssetStoreConfigured")
.WriteProperty("path", directory.FullName)); .WriteProperty("path", directory.FullName));
return TaskHelper.Done; return Task.CompletedTask;
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -68,7 +67,7 @@ namespace Squidex.Infrastructure.Assets
{ {
sourceFile.CopyTo(targetFile.FullName); sourceFile.CopyTo(targetFile.FullName);
return TaskHelper.Done; return Task.CompletedTask;
} }
catch (IOException) when (targetFile.Exists) catch (IOException) when (targetFile.Exists)
{ {
@ -124,7 +123,7 @@ namespace Squidex.Infrastructure.Assets
file.Delete(); file.Delete();
return TaskHelper.Done; return Task.CompletedTask;
} }
private FileInfo GetFile(string fileName) private FileInfo GetFile(string fileName)

2
backend/src/Squidex.Infrastructure/Assets/MemoryAssetStore.cs

@ -107,7 +107,7 @@ namespace Squidex.Infrastructure.Assets
streams.TryRemove(fileName, out _); streams.TryRemove(fileName, out _);
return TaskHelper.Done; return Task.CompletedTask;
} }
} }
} }

3
backend/src/Squidex.Infrastructure/Commands/CommandExtensions.cs

@ -6,7 +6,6 @@
// ========================================================================== // ==========================================================================
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Infrastructure.Commands namespace Squidex.Infrastructure.Commands
{ {
@ -14,7 +13,7 @@ namespace Squidex.Infrastructure.Commands
{ {
public static Task HandleAsync(this ICommandMiddleware commandMiddleware, CommandContext context) public static Task HandleAsync(this ICommandMiddleware commandMiddleware, CommandContext context)
{ {
return commandMiddleware.HandleAsync(context, x => TaskHelper.Done); return commandMiddleware.HandleAsync(context, x => Task.CompletedTask);
} }
} }
} }

2
backend/src/Squidex.Infrastructure/Commands/DomainObjectBase.cs

@ -209,7 +209,7 @@ namespace Squidex.Infrastructure.Commands
public virtual Task RebuildStateAsync() public virtual Task RebuildStateAsync()
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
protected virtual void OnSetup() protected virtual void OnSetup()

10
backend/src/Squidex.Infrastructure/EventSourcing/Grains/EventConsumerGrain.cs

@ -55,7 +55,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains
eventConsumer = eventConsumerFactory(key); eventConsumer = eventConsumerFactory(key);
return TaskHelper.Done; return Task.CompletedTask;
} }
public Task<Immutable<EventConsumerInfo>> GetStateAsync() public Task<Immutable<EventConsumerInfo>> GetStateAsync()
@ -72,7 +72,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains
{ {
if (subscription.Value != currentSubscription) if (subscription.Value != currentSubscription)
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
return DoAndUpdateStateAsync(async () => return DoAndUpdateStateAsync(async () =>
@ -95,7 +95,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains
{ {
if (subscription.Value != currentSubscription) if (subscription.Value != currentSubscription)
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
return DoAndUpdateStateAsync(() => return DoAndUpdateStateAsync(() =>
@ -113,7 +113,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains
Subscribe(state.Value.Position); Subscribe(state.Value.Position);
} }
return TaskHelper.Done; return Task.CompletedTask;
} }
public async Task<Immutable<EventConsumerInfo>> StartAsync() public async Task<Immutable<EventConsumerInfo>> StartAsync()
@ -168,7 +168,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains
private Task DoAndUpdateStateAsync(Action action, [CallerMemberName] string? caller = null) 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<Task> action, [CallerMemberName] string? caller = null) private async Task DoAndUpdateStateAsync(Func<Task> action, [CallerMemberName] string? caller = null)

3
backend/src/Squidex.Infrastructure/LanguagesInitializer.cs

@ -8,7 +8,6 @@
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Infrastructure namespace Squidex.Infrastructure
{ {
@ -33,7 +32,7 @@ namespace Squidex.Infrastructure
} }
} }
return TaskHelper.Done; return Task.CompletedTask;
} }
} }
} }

3
backend/src/Squidex.Infrastructure/Log/Store/BackgroundRequestLogStore.cs

@ -10,7 +10,6 @@ using System.Collections.Concurrent;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Infrastructure.Tasks;
using Squidex.Infrastructure.Timers; using Squidex.Infrastructure.Timers;
namespace Squidex.Infrastructure.Log.Store namespace Squidex.Infrastructure.Log.Store
@ -85,7 +84,7 @@ namespace Squidex.Infrastructure.Log.Store
jobs.Enqueue(request); jobs.Enqueue(request);
return TaskHelper.Done; return Task.CompletedTask;
} }
} }
} }

6
backend/src/Squidex.Infrastructure/Orleans/ActivationLimit.cs

@ -6,10 +6,10 @@
// ========================================================================== // ==========================================================================
using System; using System;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Orleans; using Orleans;
using Orleans.Runtime; using Orleans.Runtime;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Infrastructure.Orleans namespace Squidex.Infrastructure.Orleans
{ {
@ -57,13 +57,13 @@ namespace Squidex.Infrastructure.Orleans
ReportIAmAlive(); ReportIAmAlive();
return TaskHelper.Done; return Task.CompletedTask;
}, },
ct => ct =>
{ {
ReportIAmDead(); ReportIAmDead();
return TaskHelper.Done; return Task.CompletedTask;
}); });
} }

3
backend/src/Squidex.Infrastructure/Orleans/GrainOfGuid.cs

@ -10,7 +10,6 @@ using System.Threading.Tasks;
using Orleans; using Orleans;
using Orleans.Core; using Orleans.Core;
using Orleans.Runtime; using Orleans.Runtime;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Infrastructure.Orleans namespace Squidex.Infrastructure.Orleans
{ {
@ -41,7 +40,7 @@ namespace Squidex.Infrastructure.Orleans
protected virtual Task OnActivateAsync(Guid key) protected virtual Task OnActivateAsync(Guid key)
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
} }
} }

5
backend/src/Squidex.Infrastructure/Orleans/GrainOfString.cs

@ -9,7 +9,6 @@ using System.Threading.Tasks;
using Orleans; using Orleans;
using Orleans.Core; using Orleans.Core;
using Orleans.Runtime; using Orleans.Runtime;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Infrastructure.Orleans namespace Squidex.Infrastructure.Orleans
{ {
@ -41,12 +40,12 @@ namespace Squidex.Infrastructure.Orleans
protected virtual Task OnLoadAsync(string key) protected virtual Task OnLoadAsync(string key)
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
protected virtual Task OnActivateAsync(string key) protected virtual Task OnActivateAsync(string key)
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
} }
} }

3
backend/src/Squidex.Infrastructure/Orleans/Indexes/UniqueNameIndexGrain.cs

@ -9,7 +9,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Orleans; using Orleans;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Infrastructure.Orleans.Indexes namespace Squidex.Infrastructure.Orleans.Indexes
{ {
@ -80,7 +79,7 @@ namespace Squidex.Infrastructure.Orleans.Indexes
{ {
reservations.Remove(token ?? string.Empty); reservations.Remove(token ?? string.Empty);
return TaskHelper.Done; return Task.CompletedTask;
} }
public async Task RemoveAsync(T id) public async Task RemoveAsync(T id)

3
backend/src/Squidex.Infrastructure/Orleans/LockGrain.cs

@ -9,7 +9,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Infrastructure.Orleans namespace Squidex.Infrastructure.Orleans
{ {
@ -40,7 +39,7 @@ namespace Squidex.Infrastructure.Orleans
locks.Remove(key); locks.Remove(key);
} }
return TaskHelper.Done; return Task.CompletedTask;
} }
} }
} }

4
backend/src/Squidex.Infrastructure/Tasks/SingleThreadedDispatcher.cs

@ -39,7 +39,7 @@ namespace Squidex.Infrastructure.Tasks
{ {
Guard.NotNull(action); Guard.NotNull(action);
return block.SendAsync(() => { action(); return TaskHelper.Done; }); return block.SendAsync(() => { action(); return Task.CompletedTask; });
} }
public async Task StopAndWaitAsync() public async Task StopAndWaitAsync()
@ -58,7 +58,7 @@ namespace Squidex.Infrastructure.Tasks
{ {
if (isStopped) if (isStopped)
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
return action(); return action();

2
backend/src/Squidex.Infrastructure/Tasks/TaskExtensions.cs

@ -76,7 +76,7 @@ namespace Squidex.Infrastructure.Tasks
{ {
action(x); action(x);
return TaskHelper.Done; return Task.CompletedTask;
}; };
} }

27
backend/src/Squidex.Infrastructure/Tasks/TaskHelper.cs

@ -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<bool> False = CreateResultTask(false);
public static readonly Task<bool> True = CreateResultTask(true);
private static Task<bool> CreateResultTask(bool value)
{
var result = new TaskCompletionSource<bool>();
result.SetResult(value);
return result.Task;
}
}
}

3
backend/src/Squidex.Infrastructure/UsageTracking/BackgroundUsageTracker.cs

@ -12,7 +12,6 @@ using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Squidex.Infrastructure.Log; using Squidex.Infrastructure.Log;
using Squidex.Infrastructure.Tasks;
using Squidex.Infrastructure.Timers; using Squidex.Infrastructure.Timers;
namespace Squidex.Infrastructure.UsageTracking 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)); usages.AddOrUpdate((key, category), _ => new Usage(elapsedMs, weight), (k, x) => x.Add(elapsedMs, weight));
} }
return TaskHelper.Done; return Task.CompletedTask;
} }
public async Task<IReadOnlyDictionary<string, IReadOnlyList<DateUsage>>> QueryAsync(string key, DateTime fromDate, DateTime toDate) public async Task<IReadOnlyDictionary<string, IReadOnlyList<DateUsage>>> QueryAsync(string key, DateTime fromDate, DateTime toDate)

3
backend/src/Squidex.Web/ApiPermissionAttribute.cs

@ -11,7 +11,6 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.AspNetCore.Mvc.Filters;
using Squidex.Infrastructure.Security; using Squidex.Infrastructure.Security;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Web namespace Squidex.Web
{ {
@ -62,7 +61,7 @@ namespace Squidex.Web
{ {
context.Result = new StatusCodeResult(403); context.Result = new StatusCodeResult(403);
return TaskHelper.Done; return Task.CompletedTask;
} }
} }

3
backend/src/Squidex/Areas/IdentityServer/Controllers/Account/AccountController.cs

@ -25,7 +25,6 @@ using Squidex.Config;
using Squidex.Domain.Users; using Squidex.Domain.Users;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Log; using Squidex.Infrastructure.Log;
using Squidex.Infrastructure.Tasks;
using Squidex.Shared; using Squidex.Shared;
using Squidex.Shared.Identity; using Squidex.Shared.Identity;
using Squidex.Shared.Users; using Squidex.Shared.Users;
@ -352,7 +351,7 @@ namespace Squidex.Areas.IdentityServer.Controllers.Account
{ {
if (isFirst || !identityOptions.LockAutomatically) if (isFirst || !identityOptions.LockAutomatically)
{ {
return TaskHelper.True; return Task.FromResult(true);
} }
return MakeIdentityOperation(() => userManager.SetLockoutEndDateAsync(user.Identity, DateTimeOffset.UtcNow.AddYears(100))); return MakeIdentityOperation(() => userManager.SetLockoutEndDateAsync(user.Identity, DateTimeOffset.UtcNow.AddYears(100)));

3
backend/src/Squidex/Config/Authentication/GoogleHandler.cs

@ -10,7 +10,6 @@ using System.Text.Json;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.OAuth; using Microsoft.AspNetCore.Authentication.OAuth;
using Squidex.Infrastructure.Tasks;
using Squidex.Shared.Identity; using Squidex.Shared.Identity;
namespace Squidex.Config.Authentication namespace Squidex.Config.Authentication
@ -21,7 +20,7 @@ namespace Squidex.Config.Authentication
{ {
context.Response.Redirect(context.RedirectUri + "&prompt=select_account"); context.Response.Redirect(context.RedirectUri + "&prompt=select_account");
return TaskHelper.Done; return Task.CompletedTask;
} }
public override Task CreatingTicket(OAuthCreatingTicketContext context) public override Task CreatingTicket(OAuthCreatingTicketContext context)

2
backend/src/Squidex/Config/Domain/ContentsServices.cs

@ -76,7 +76,7 @@ namespace Squidex.Config.Domain
.AsOptional<IWorkflowsValidator>(); .AsOptional<IWorkflowsValidator>();
services.AddSingletonAs<LuceneTextIndex>() services.AddSingletonAs<LuceneTextIndex>()
.As<IContentTextIndex>(); .As<ITextIndex>();
services.AddSingletonAs<TextIndexingProcess>() services.AddSingletonAs<TextIndexingProcess>()
.As<IEventConsumer>(); .As<IEventConsumer>();

3
backend/src/Squidex/Config/Domain/SerializationInitializer.cs

@ -15,7 +15,6 @@ using Squidex.Infrastructure;
using Squidex.Infrastructure.Json; using Squidex.Infrastructure.Json;
using Squidex.Infrastructure.MongoDb; using Squidex.Infrastructure.MongoDb;
using Squidex.Infrastructure.Orleans; using Squidex.Infrastructure.Orleans;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Config.Domain namespace Squidex.Config.Domain
{ {
@ -39,7 +38,7 @@ namespace Squidex.Config.Domain
SetupOrleans(); SetupOrleans();
SetupActions(); SetupActions();
return TaskHelper.Done; return Task.CompletedTask;
} }
private void SetupActions() private void SetupActions()

3
backend/src/Squidex/Config/Startup/LogConfigurationHost.cs

@ -12,7 +12,6 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Squidex.Infrastructure.Log; using Squidex.Infrastructure.Log;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Config.Startup namespace Squidex.Config.Startup
{ {
@ -45,7 +44,7 @@ namespace Squidex.Config.Startup
} }
})); }));
return TaskHelper.Done; return Task.CompletedTask;
} }
} }
} }

3
backend/src/Squidex/Config/Startup/SafeHostedService.cs

@ -9,7 +9,6 @@ using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Squidex.Infrastructure.Log; using Squidex.Infrastructure.Log;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Config.Startup namespace Squidex.Config.Startup
{ {
@ -42,7 +41,7 @@ namespace Squidex.Config.Startup
protected virtual Task StopAsync(ISemanticLog log, CancellationToken ct) protected virtual Task StopAsync(ISemanticLog log, CancellationToken ct)
{ {
return TaskHelper.Done; return Task.CompletedTask;
} }
} }
} }

5
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;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Tasks;
using Xunit; using Xunit;
#pragma warning disable IDE0067 // Dispose objects before losing scope #pragma warning disable IDE0067 // Dispose objects before losing scope
@ -175,7 +174,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
{ {
rebuildAssets.Add(id); rebuildAssets.Add(id);
return TaskHelper.Done; return Task.CompletedTask;
}); });
A.CallTo(() => rebuilder.InsertManyAsync<AssetDomainObject, AssetState>(A<IdSource>._, A<CancellationToken>._)) A.CallTo(() => rebuilder.InsertManyAsync<AssetDomainObject, AssetState>(A<IdSource>._, A<CancellationToken>._))
@ -219,7 +218,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
{ {
rebuildAssets.Add(id); rebuildAssets.Add(id);
return TaskHelper.Done; return Task.CompletedTask;
}); });
A.CallTo(() => rebuilder.InsertManyAsync<AssetFolderDomainObject, AssetFolderState>(A<IdSource>._, A<CancellationToken>._)) A.CallTo(() => rebuilder.InsertManyAsync<AssetFolderDomainObject, AssetFolderState>(A<IdSource>._, A<CancellationToken>._))

5
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.Json;
using Squidex.Infrastructure.Reflection; using Squidex.Infrastructure.Reflection;
using Squidex.Infrastructure.States; using Squidex.Infrastructure.States;
using Squidex.Infrastructure.Tasks;
using Xunit; using Xunit;
namespace Squidex.Domain.Apps.Entities.Backup namespace Squidex.Domain.Apps.Entities.Backup
@ -109,7 +108,7 @@ namespace Squidex.Domain.Apps.Entities.Backup
{ {
innerStream.WriteByte((byte)index); innerStream.WriteByte((byte)index);
return TaskHelper.Done; return Task.CompletedTask;
}); });
} }
else if (index % 37 == 0) else if (index % 37 == 0)
@ -139,7 +138,7 @@ namespace Squidex.Domain.Apps.Entities.Backup
Assert.Equal((byte)index, byteRead); Assert.Equal((byte)index, byteRead);
return TaskHelper.Done; return Task.CompletedTask;
}); });
} }
else if (index % 37 == 0) else if (index % 37 == 0)

3
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;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.Orleans; using Squidex.Infrastructure.Orleans;
using Squidex.Infrastructure.Tasks;
using Squidex.Shared.Users; using Squidex.Shared.Users;
using Xunit; using Xunit;
@ -60,7 +59,7 @@ namespace Squidex.Domain.Apps.Entities.Comments
{ {
isNextCalled = true; isNextCalled = true;
return TaskHelper.Done; return Task.CompletedTask;
}); });
Assert.True(isNextCalled); Assert.True(isNextCalled);

3
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;
using Squidex.Infrastructure.Commands; using Squidex.Infrastructure.Commands;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Tasks;
using Xunit; using Xunit;
namespace Squidex.Domain.Apps.Entities.Contents namespace Squidex.Domain.Apps.Entities.Contents
@ -87,7 +86,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
{ {
rebuildContents.Add(id); rebuildContents.Add(id);
return TaskHelper.Done; return Task.CompletedTask;
}); });
A.CallTo(() => rebuilder.InsertManyAsync<ContentDomainObject, ContentState>(A<IdSource>._, A<CancellationToken>._)) A.CallTo(() => rebuilder.InsertManyAsync<ContentDomainObject, ContentState>(A<IdSource>._, A<CancellationToken>._))

2
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<IAppProvider>(); private readonly IAppProvider appProvider = A.Fake<IAppProvider>();
private readonly IUrlGenerator urlGenerator = A.Fake<IUrlGenerator>(); private readonly IUrlGenerator urlGenerator = A.Fake<IUrlGenerator>();
private readonly IContentTextIndex contentIndex = A.Fake<IContentTextIndex>(); private readonly ITextIndex contentIndex = A.Fake<ITextIndex>();
private readonly IContentQueryService contentQuery = A.Fake<IContentQueryService>(); private readonly IContentQueryService contentQuery = A.Fake<IContentQueryService>();
private readonly NamedId<Guid> appId = NamedId.Of(Guid.NewGuid(), "my-app"); private readonly NamedId<Guid> appId = NamedId.Of(Guid.NewGuid(), "my-app");
private readonly NamedId<Guid> schemaId1 = NamedId.Of(Guid.NewGuid(), "my-schema1"); private readonly NamedId<Guid> schemaId1 = NamedId.Of(Guid.NewGuid(), "my-schema1");

4
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/MongoDb/ContentsQueryFixture.cs

@ -147,9 +147,9 @@ namespace Squidex.Domain.Apps.Entities.Contents.MongoDb
return appProvider; return appProvider;
} }
private static IContentTextIndex CreateTextIndexer() private static ITextIndex CreateTextIndexer()
{ {
var textIndexer = A.Fake<IContentTextIndex>(); var textIndexer = A.Fake<ITextIndex>();
A.CallTo(() => textIndexer.SearchAsync(A<string>._, A<IAppEntity>._, A<SearchFilter>._, A<SearchScope>._)) A.CallTo(() => textIndexer.SearchAsync(A<string>._, A<IAppEntity>._, A<SearchFilter>._, A<SearchScope>._))
.Returns(new List<Guid> { Guid.NewGuid() }); .Returns(new List<Guid> { Guid.NewGuid() });

3
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/MongoDb/ContentsQueryTests.cs

@ -12,7 +12,6 @@ using System.Threading.Tasks;
using NodaTime; using NodaTime;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.Queries; using Squidex.Infrastructure.Queries;
using Squidex.Infrastructure.Tasks;
using Xunit; using Xunit;
using F = Squidex.Infrastructure.Queries.ClrFilter; using F = Squidex.Infrastructure.Queries.ClrFilter;
@ -75,7 +74,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.MongoDb
{ {
var time = SystemClock.Instance.GetCurrentInstant(); var time = SystemClock.Instance.GetCurrentInstant();
await _.ContentRepository.QueryScheduledWithoutDataAsync(time, _ => TaskHelper.Done); await _.ContentRepository.QueryScheduledWithoutDataAsync(time, _ => Task.CompletedTask);
} }
[Fact] [Fact]

2
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 public interface IIndexerFactory
{ {
Task<IContentTextIndex> CreateAsync(Guid schemaId); Task<ITextIndex> CreateAsync(Guid schemaId);
Task CleanupAsync(); Task CleanupAsync();
} }

8
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Text/LuceneIndexFactory.cs

@ -28,13 +28,15 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text
.ReturnsLazily(() => grain); .ReturnsLazily(() => grain);
} }
public async Task<IContentTextIndex> CreateAsync(Guid schemaId) public async Task<ITextIndex> CreateAsync(Guid schemaId)
{ {
grain = new LuceneTextIndexGrain(new IndexManager(storage, A.Fake<ISemanticLog>())); var indexManager = new IndexManager(storage, A.Fake<ISemanticLog>());
grain = new LuceneTextIndexGrain(indexManager);
await grain.ActivateAsync(schemaId); await grain.ActivateAsync(schemaId);
return new LuceneTextIndex(grainFactory); return new LuceneTextIndex(grainFactory, indexManager);
} }
public async Task CleanupAsync() public async Task CleanupAsync()

5
backend/tests/Squidex.Infrastructure.Tests/Commands/InMemoryCommandBusTests.cs

@ -8,7 +8,6 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using FakeItEasy; using FakeItEasy;
using Squidex.Infrastructure.Tasks;
using Xunit; using Xunit;
namespace Squidex.Infrastructure.Commands namespace Squidex.Infrastructure.Commands
@ -27,7 +26,7 @@ namespace Squidex.Infrastructure.Commands
context.Complete(true); context.Complete(true);
return TaskHelper.True; return Task.FromResult(true);
} }
} }
@ -39,7 +38,7 @@ namespace Squidex.Infrastructure.Commands
{ {
LastCommand = context.Command; LastCommand = context.Command;
return TaskHelper.Done; return Task.CompletedTask;
} }
} }

5
backend/tests/Squidex.Infrastructure.Tests/Commands/LogCommandMiddlewareTests.cs

@ -10,7 +10,6 @@ using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using FakeItEasy; using FakeItEasy;
using Squidex.Infrastructure.Log; using Squidex.Infrastructure.Log;
using Squidex.Infrastructure.Tasks;
using Xunit; using Xunit;
namespace Squidex.Infrastructure.Commands namespace Squidex.Infrastructure.Commands
@ -51,7 +50,7 @@ namespace Squidex.Infrastructure.Commands
{ {
context.Complete(true); context.Complete(true);
return TaskHelper.Done; return Task.CompletedTask;
}); });
Assert.Equal(log.LogLevels, new Dictionary<SemanticLogLevel, int> Assert.Equal(log.LogLevels, new Dictionary<SemanticLogLevel, int>
@ -84,7 +83,7 @@ namespace Squidex.Infrastructure.Commands
{ {
var context = new CommandContext(command, commandBus); 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<SemanticLogLevel, int> Assert.Equal(log.LogLevels, new Dictionary<SemanticLogLevel, int>
{ {

3
backend/tests/Squidex.Infrastructure.Tests/Commands/ReadonlyCommandMiddlewareTests.cs

@ -8,7 +8,6 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using FakeItEasy; using FakeItEasy;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using Squidex.Infrastructure.Tasks;
using Xunit; using Xunit;
namespace Squidex.Infrastructure.Commands namespace Squidex.Infrastructure.Commands
@ -55,7 +54,7 @@ namespace Squidex.Infrastructure.Commands
{ {
context.Complete(true); context.Complete(true);
return TaskHelper.Done; return Task.CompletedTask;
}); });
} }
} }

7
backend/tests/Squidex.Infrastructure.Tests/EventSourcing/EventStoreTests.cs

@ -11,7 +11,6 @@ using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using FluentAssertions; using FluentAssertions;
using Squidex.Infrastructure.Tasks;
using Xunit; using Xunit;
namespace Squidex.Infrastructure.EventSourcing namespace Squidex.Infrastructure.EventSourcing
@ -38,7 +37,7 @@ namespace Squidex.Infrastructure.EventSourcing
Events.Add(storedEvent); Events.Add(storedEvent);
return TaskHelper.Done; return Task.CompletedTask;
} }
} }
@ -323,7 +322,7 @@ namespace Squidex.Infrastructure.EventSourcing
{ {
var readEvents = new List<StoredEvent>(); var readEvents = new List<StoredEvent>();
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); await Task.Delay(500, cts.Token);
@ -347,7 +346,7 @@ namespace Squidex.Infrastructure.EventSourcing
{ {
var readEvents = new List<StoredEvent>(); var readEvents = new List<StoredEvent>();
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); await Task.Delay(500, cts.Token);

3
backend/tests/Squidex.Infrastructure.Tests/Migrations/MigratorTests.cs

@ -11,7 +11,6 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using FakeItEasy; using FakeItEasy;
using Squidex.Infrastructure.Log; using Squidex.Infrastructure.Log;
using Squidex.Infrastructure.Tasks;
using Xunit; using Xunit;
namespace Squidex.Infrastructure.Migrations namespace Squidex.Infrastructure.Migrations
@ -60,7 +59,7 @@ namespace Squidex.Infrastructure.Migrations
version = newVersion; version = newVersion;
} }
return TaskHelper.Done; return Task.CompletedTask;
} }
} }

9
backend/tests/Squidex.Infrastructure.Tests/MongoDb/MongoExtensionsTests.cs

@ -11,7 +11,6 @@ using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using MongoDB.Driver; using MongoDB.Driver;
using Squidex.Infrastructure.Tasks;
using Xunit; using Xunit;
namespace Squidex.Infrastructure.MongoDb namespace Squidex.Infrastructure.MongoDb
@ -82,7 +81,7 @@ namespace Squidex.Infrastructure.MongoDb
await cursor.ForEachPipelineAsync(x => await cursor.ForEachPipelineAsync(x =>
{ {
result.Add(x); result.Add(x);
return TaskHelper.Done; return Task.CompletedTask;
}); });
Assert.Equal(new List<int> { 0, 1, 2, 3, 4, 5 }, result); Assert.Equal(new List<int> { 0, 1, 2, 3, 4, 5 }, result);
@ -102,7 +101,7 @@ namespace Squidex.Infrastructure.MongoDb
return cursor.ForEachPipelineAsync(x => return cursor.ForEachPipelineAsync(x =>
{ {
result.Add(x); result.Add(x);
return TaskHelper.Done; return Task.CompletedTask;
}); });
}); });
} }
@ -129,7 +128,7 @@ namespace Squidex.Infrastructure.MongoDb
} }
result.Add(x); result.Add(x);
return TaskHelper.Done; return Task.CompletedTask;
}); });
}); });
} }
@ -157,7 +156,7 @@ namespace Squidex.Infrastructure.MongoDb
result.Add(x); result.Add(x);
return TaskHelper.Done; return Task.CompletedTask;
}, cts.Token); }, cts.Token);
}); });
} }

2
backend/tests/Squidex.Infrastructure.Tests/Tasks/SingleThreadedDispatcherTests.cs

@ -28,7 +28,7 @@ namespace Squidex.Infrastructure.Tasks
{ {
target.Add(item); target.Add(item);
return TaskHelper.Done; return Task.CompletedTask;
}).Forget(); }).Forget();
} }

4
backend/tests/Squidex.Infrastructure.Tests/Timers/CompletionTimerTests.cs

@ -5,7 +5,7 @@
// All rights reserved. Licensed under the MIT license. // All rights reserved. Licensed under the MIT license.
// ========================================================================== // ==========================================================================
using Squidex.Infrastructure.Tasks; using System.Threading.Tasks;
using Xunit; using Xunit;
namespace Squidex.Infrastructure.Timers namespace Squidex.Infrastructure.Timers
@ -21,7 +21,7 @@ namespace Squidex.Infrastructure.Timers
{ {
called = true; called = true;
return TaskHelper.Done; return Task.CompletedTask;
}, 2000); }, 2000);
timer.SkipCurrentDelay(); timer.SkipCurrentDelay();

3
backend/tests/Squidex.Web.Tests/Pipeline/CleanupHostMiddlewareTests.cs

@ -7,7 +7,6 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Squidex.Infrastructure.Tasks;
using Xunit; using Xunit;
#pragma warning disable RECS0092 // Convert field to readonly #pragma warning disable RECS0092 // Convert field to readonly
@ -25,7 +24,7 @@ namespace Squidex.Web.Pipeline
{ {
isNextCalled = true; isNextCalled = true;
return TaskHelper.Done; return Task.CompletedTask;
} }
sut = new CleanupHostMiddleware(Next); sut = new CleanupHostMiddleware(Next);

3
backend/tests/Squidex.Web.Tests/Pipeline/EnforceHttpsMiddlewareTests.cs

@ -7,7 +7,6 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Squidex.Infrastructure.Tasks;
using Xunit; using Xunit;
using Options = Microsoft.Extensions.Options.Options; using Options = Microsoft.Extensions.Options.Options;
@ -26,7 +25,7 @@ namespace Squidex.Web.Pipeline
{ {
isNextCalled = true; isNextCalled = true;
return TaskHelper.Done; return Task.CompletedTask;
}; };
sut = new EnforceHttpsMiddleware(Options.Create(options)); sut = new EnforceHttpsMiddleware(Options.Create(options));

7
backend/tools/Migrate_01/Migrations/PopulateGrainIndexes.cs

@ -18,7 +18,6 @@ using Squidex.Domain.Apps.Events.Schemas;
using Squidex.Infrastructure; using Squidex.Infrastructure;
using Squidex.Infrastructure.EventSourcing; using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Migrations; using Squidex.Infrastructure.Migrations;
using Squidex.Infrastructure.Tasks;
namespace Migrate_01.Migrations namespace Migrate_01.Migrations
{ {
@ -109,7 +108,7 @@ namespace Migrate_01.Migrations
break; break;
} }
return TaskHelper.Done; return Task.CompletedTask;
}, "^app\\-"); }, "^app\\-");
await indexApps.RebuildAsync(appsByName); await indexApps.RebuildAsync(appsByName);
@ -143,7 +142,7 @@ namespace Migrate_01.Migrations
break; break;
} }
return TaskHelper.Done; return Task.CompletedTask;
}, "^rule\\-"); }, "^rule\\-");
foreach (var (appId, rules) in rulesByApp) foreach (var (appId, rules) in rulesByApp)
@ -175,7 +174,7 @@ namespace Migrate_01.Migrations
break; break;
} }
return TaskHelper.Done; return Task.CompletedTask;
}, "^schema\\-"); }, "^schema\\-");
foreach (var (appId, schemas) in schemasByApp) foreach (var (appId, schemas) in schemasByApp)

Loading…
Cancel
Save