Browse Source

* TaskHelper removed

* Cleanup in TextIndexers
* Use secondary read preference for contents.
pull/492/head
Sebastian 6 years ago
parent
commit
cf767e2dee
  1. 3
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/AllowedValuesValidator.cs
  2. 7
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/CollectionValidator.cs
  3. 5
      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. 5
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/RequiredValidator.cs
  7. 5
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/StringLengthValidator.cs
  8. 5
      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.Threading.Tasks;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
{
@ -36,7 +35,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
addError(context.Path, "Not an allowed value.");
}
return TaskHelper.Done;
return Task.CompletedTask;
}
}
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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 QueryScheduledContents queryScheduledItems;
public MongoContentCollectionAll(IMongoDatabase database, IAppProvider appProvider, IContentTextIndex indexer, IJsonSerializer serializer)
public MongoContentCollectionAll(IMongoDatabase database, IAppProvider appProvider, ITextIndex indexer, IJsonSerializer serializer)
: base(database)
{
queryContentAsync = new QueryContent(serializer);

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

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

@ -34,7 +34,7 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.Contents
StatusSerializer.Register();
}
public MongoContentRepository(IMongoDatabase database, IAppProvider appProvider, IContentTextIndex indexer, IJsonSerializer serializer)
public MongoContentRepository(IMongoDatabase database, IAppProvider appProvider, ITextIndex indexer, IJsonSerializer serializer)
{
Guard.NotNull(appProvider);
Guard.NotNull(serializer);

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

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

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
{
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;

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

@ -11,6 +11,7 @@ using System.Threading.Tasks;
using Lucene.Net.Index;
using MongoDB.Driver.GridFS;
using Squidex.Domain.Apps.Entities.Contents.Text.Lucene;
using Squidex.Infrastructure;
using LuceneDirectory = Lucene.Net.Store.Directory;
namespace Squidex.Domain.Apps.Entities.MongoDb.FullText
@ -21,6 +22,8 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.FullText
public MongoIndexStorage(IGridFSBucket<string> bucket)
{
Guard.NotNull(bucket);
this.bucket = bucket;
}
@ -36,6 +39,11 @@ namespace Squidex.Domain.Apps.Entities.MongoDb.FullText
return Task.FromResult<LuceneDirectory>(directory);
}
public Task ClearAsync()
{
return bucket.DropAsync();
}
public Task WriteAsync(LuceneDirectory directory, SnapshotDeletionPolicy snapshotter)
{
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 Squidex.Domain.Apps.Events.Assets;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Tasks;
using Squidex.Infrastructure.UsageTracking;
namespace Squidex.Domain.Apps.Entities.Assets
@ -33,7 +32,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
public Task ClearAsync()
{
return TaskHelper.Done;
return Task.CompletedTask;
}
public Task On(Envelope<IEvent> @event)
@ -50,7 +49,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
return UpdateSizeAsync(e.AppId.Id, GetDate(@event), e.DeletedSize, -1);
}
return TaskHelper.Done;
return Task.CompletedTask;
}
private static DateTime GetDate(Envelope<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.Commands;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Entities.Assets
{
@ -56,7 +55,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
return WriteAssetAsync(assetUpdated.AssetId, assetUpdated.FileVersion, context.Writer);
}
return TaskHelper.Done;
return Task.CompletedTask;
}
public async Task<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.Assets;
using Squidex.Infrastructure.Json.Objects;
using Squidex.Infrastructure.Tasks;
using TagLib;
using TagLib.Image;
using static TagLib.File;
@ -57,7 +56,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
{
Enhance(command);
return TaskHelper.Done;
return Task.CompletedTask;
}
private void Enhance(UploadAssetCommand command)

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

@ -9,7 +9,6 @@ using System.Collections.Generic;
using System.Threading.Tasks;
using Squidex.Domain.Apps.Entities.Assets.Commands;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Entities.Assets
{
@ -27,7 +26,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
}
}
return TaskHelper.Done;
return Task.CompletedTask;
}
public IEnumerable<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.Log;
using Squidex.Infrastructure.Reflection;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Entities.Assets
{
@ -60,7 +59,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
public Task ClearAsync()
{
return TaskHelper.Done;
return Task.CompletedTask;
}
public bool Handles(StoredEvent @event)

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

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

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

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

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

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

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

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

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

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.Commands;
using Squidex.Infrastructure.Log;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Entities.Contents
{
@ -61,7 +60,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
public Task ActivateAsync()
{
return TaskHelper.Done;
return Task.CompletedTask;
}
public Task PublishAsync()
@ -96,7 +95,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
public Task ReceiveReminder(string reminderName, TickStatus status)
{
return TaskHelper.Done;
return Task.CompletedTask;
}
private Task Dispatch(Func<Task> 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 IContentQueryService contentQuery;
private readonly IContentTextIndex contentTextIndexer;
private readonly ITextIndex contentTextIndexer;
private readonly IUrlGenerator urlGenerator;
public ContentsSearchSource(
IAppProvider appProvider,
IContentQueryService contentQuery,
IContentTextIndex contentTextIndexer,
ITextIndex contentTextIndexer,
IUrlGenerator urlGenerator)
{
Guard.NotNull(appProvider);

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

@ -12,7 +12,6 @@ using System.Security.Claims;
using System.Threading.Tasks;
using Squidex.Domain.Apps.Core.Contents;
using Squidex.Domain.Apps.Entities.Schemas;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Entities.Contents
{
@ -55,7 +54,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
public Task<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)

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

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

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

@ -10,7 +10,6 @@ using System.Linq;
using System.Threading.Tasks;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Caching;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Entities.Contents.Queries.Steps
{
@ -29,7 +28,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries.Steps
{
context.AddCacheHeaders(requestCache);
return TaskHelper.Done;
return Task.CompletedTask;
}
public async Task EnrichAsync(Context context, IEnumerable<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
{
[ExcludeFromCodeCoverage]
public sealed class ElasticSearchTextIndex : IContentTextIndex
public sealed class ElasticSearchTextIndex : ITextIndex
{
private const string IndexName = "contents";
private readonly ElasticLowLevelClient client;
@ -28,6 +28,11 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.Elastic
client = new ElasticLowLevelClient(config);
}
public Task ClearAsync()
{
return Task.CompletedTask;
}
public async Task ExecuteAsync(NamedId<Guid> appId, NamedId<Guid> schemaId, params IndexCommand[] 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
{
public interface IContentTextIndex
public interface ITextIndex
{
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);
}
}

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

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
{
public sealed class LuceneTextIndex : IContentTextIndex
public sealed class LuceneTextIndex : ITextIndex
{
private readonly IGrainFactory grainFactory;
private readonly IndexManager indexManager;
public LuceneTextIndex(IGrainFactory grainFactory)
public LuceneTextIndex(IGrainFactory grainFactory, IndexManager indexManager)
{
Guard.NotNull(grainFactory);
Guard.NotNull(indexManager);
this.grainFactory = grainFactory;
this.indexManager = indexManager;
}
public Task ClearAsync()
{
return indexManager.ClearAsync();
}
public async Task<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;
}
public Task ClearAsync()
{
return Task.CompletedTask;
}
public async Task WriteAsync(LuceneDirectory directory, SnapshotDeletionPolicy snapshotter)
{
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));
}
public Task ClearAsync()
{
return Task.CompletedTask;
}
public Task WriteAsync(LuceneDirectory directory, SnapshotDeletionPolicy snapshotter)
{
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 ClearAsync();
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.Collections.Generic;
using System.Threading.Tasks;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Entities.Contents.Text.State
{
@ -20,7 +19,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.State
{
states.Clear();
return TaskHelper.Done;
return Task.CompletedTask;
}
public Task<TextContentState?> GetAsync(Guid contentId)
@ -37,14 +36,14 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text.State
{
states.Remove(contentId);
return TaskHelper.Done;
return Task.CompletedTask;
}
public Task SetAsync(TextContentState state)
{
states[state.ContentId] = state;
return TaskHelper.Done;
return Task.CompletedTask;
}
}
}

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

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

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

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.EventSourcing;
using Squidex.Infrastructure.Log;
using Squidex.Infrastructure.Tasks;
using Squidex.Shared.Users;
namespace Squidex.Domain.Apps.Entities.History.Notifications
@ -52,7 +51,7 @@ namespace Squidex.Domain.Apps.Entities.History.Notifications
public Task ClearAsync()
{
return TaskHelper.Done;
return Task.CompletedTask;
}
public async Task On(Envelope<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.Infrastructure;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Domain.Apps.Entities.Rules
{
@ -43,7 +42,7 @@ namespace Squidex.Domain.Apps.Entities.Rules
break;
}
return TaskHelper.True;
return Task.FromResult(true);
}
public Task RestoreAsync(RestoreContext context)

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

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

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

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

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

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

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

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

@ -12,7 +12,6 @@ using System.Threading;
using System.Threading.Tasks;
using Microsoft.Azure.Documents;
using Squidex.Infrastructure.Log;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Infrastructure.EventSourcing
{
@ -37,7 +36,7 @@ namespace Squidex.Infrastructure.EventSourcing
ThrowIfDisposed();
return TaskHelper.Done;
return Task.CompletedTask;
}
public async Task<IReadOnlyList<StoredEvent>> QueryLatestAsync(string streamName, int count)
@ -74,7 +73,7 @@ namespace Squidex.Infrastructure.EventSourcing
result.Add(new StoredEvent(streamName, eventToken, eventStreamOffset, eventData));
}
return TaskHelper.Done;
return Task.CompletedTask;
});
IEnumerable<StoredEvent> ordered = result.OrderBy(x => x.EventStreamNumber);
@ -120,7 +119,7 @@ namespace Squidex.Infrastructure.EventSourcing
}
}
return TaskHelper.Done;
return Task.CompletedTask;
});
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.ChangeFeedProcessor.FeedProcessing;
using Newtonsoft.Json;
using Squidex.Infrastructure.Tasks;
using Builder = Microsoft.Azure.Documents.ChangeFeedProcessor.ChangeFeedProcessorBuilder;
using Collection = Microsoft.Azure.Documents.ChangeFeedProcessor.DocumentCollectionInfo;
using Options = Microsoft.Azure.Documents.ChangeFeedProcessor.ChangeFeedProcessorOptions;
@ -104,7 +103,7 @@ namespace Squidex.Infrastructure.EventSourcing
public Task OpenAsync(IChangeFeedObserverContext context)
{
return TaskHelper.Done;
return Task.CompletedTask;
}
public async Task ProcessChangesAsync(IChangeFeedObserverContext context, IReadOnlyList<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.Exceptions;
using Squidex.Infrastructure.Json;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Infrastructure.EventSourcing
{
@ -48,7 +47,7 @@ namespace Squidex.Infrastructure.EventSourcing
{
subscription.Stop();
return TaskHelper.Done;
return Task.CompletedTask;
}
public void WakeUp()

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

@ -10,7 +10,6 @@ using System.Globalization;
using System.Threading;
using System.Threading.Tasks;
using MongoDB.Driver;
using Squidex.Infrastructure.Tasks;
#pragma warning disable RECS0108 // Warns about static fields in generic types
@ -81,7 +80,7 @@ namespace Squidex.Infrastructure.MongoDb
protected virtual Task SetupCollectionAsync(IMongoCollection<TEntity> collection, CancellationToken ct = default)
{
return TaskHelper.Done;
return Task.CompletedTask;
}
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 Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Json;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Infrastructure.CQRS.Events
{
@ -73,7 +72,7 @@ namespace Squidex.Infrastructure.CQRS.Events
throw new ConfigurationException($"RabbitMq event bus failed to connect to {connectionFactory.Endpoint}");
}
return TaskHelper.Done;
return Task.CompletedTask;
}
catch (Exception e)
{
@ -88,7 +87,7 @@ namespace Squidex.Infrastructure.CQRS.Events
public Task ClearAsync()
{
return TaskHelper.Done;
return Task.CompletedTask;
}
public Task On(Envelope<IEvent> @event)
@ -98,7 +97,7 @@ namespace Squidex.Infrastructure.CQRS.Events
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.Tasks;
using Squidex.Infrastructure.Log;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Infrastructure.Assets
{
@ -43,7 +42,7 @@ namespace Squidex.Infrastructure.Assets
.WriteProperty("action", "FolderAssetStoreConfigured")
.WriteProperty("path", directory.FullName));
return TaskHelper.Done;
return Task.CompletedTask;
}
catch (Exception ex)
{
@ -68,7 +67,7 @@ namespace Squidex.Infrastructure.Assets
{
sourceFile.CopyTo(targetFile.FullName);
return TaskHelper.Done;
return Task.CompletedTask;
}
catch (IOException) when (targetFile.Exists)
{
@ -124,7 +123,7 @@ namespace Squidex.Infrastructure.Assets
file.Delete();
return TaskHelper.Done;
return Task.CompletedTask;
}
private FileInfo GetFile(string fileName)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -76,7 +76,7 @@ namespace Squidex.Infrastructure.Tasks
{
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.Tasks;
using Squidex.Infrastructure.Log;
using Squidex.Infrastructure.Tasks;
using Squidex.Infrastructure.Timers;
namespace Squidex.Infrastructure.UsageTracking
@ -109,7 +108,7 @@ namespace Squidex.Infrastructure.UsageTracking
usages.AddOrUpdate((key, category), _ => new Usage(elapsedMs, weight), (k, x) => x.Add(elapsedMs, weight));
}
return TaskHelper.Done;
return Task.CompletedTask;
}
public async Task<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.Filters;
using Squidex.Infrastructure.Security;
using Squidex.Infrastructure.Tasks;
namespace Squidex.Web
{
@ -62,7 +61,7 @@ namespace Squidex.Web
{
context.Result = new StatusCodeResult(403);
return TaskHelper.Done;
return Task.CompletedTask;
}
}

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

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

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

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

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

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

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

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

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

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

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

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

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.Commands;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Tasks;
using Xunit;
#pragma warning disable IDE0067 // Dispose objects before losing scope
@ -175,7 +174,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
{
rebuildAssets.Add(id);
return TaskHelper.Done;
return Task.CompletedTask;
});
A.CallTo(() => rebuilder.InsertManyAsync<AssetDomainObject, AssetState>(A<IdSource>._, A<CancellationToken>._))
@ -219,7 +218,7 @@ namespace Squidex.Domain.Apps.Entities.Assets
{
rebuildAssets.Add(id);
return TaskHelper.Done;
return Task.CompletedTask;
});
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.Reflection;
using Squidex.Infrastructure.States;
using Squidex.Infrastructure.Tasks;
using Xunit;
namespace Squidex.Domain.Apps.Entities.Backup
@ -109,7 +108,7 @@ namespace Squidex.Domain.Apps.Entities.Backup
{
innerStream.WriteByte((byte)index);
return TaskHelper.Done;
return Task.CompletedTask;
});
}
else if (index % 37 == 0)
@ -139,7 +138,7 @@ namespace Squidex.Domain.Apps.Entities.Backup
Assert.Equal((byte)index, byteRead);
return TaskHelper.Done;
return Task.CompletedTask;
});
}
else if (index % 37 == 0)

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

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.Commands;
using Squidex.Infrastructure.EventSourcing;
using Squidex.Infrastructure.Tasks;
using Xunit;
namespace Squidex.Domain.Apps.Entities.Contents
@ -87,7 +86,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
{
rebuildContents.Add(id);
return TaskHelper.Done;
return Task.CompletedTask;
});
A.CallTo(() => rebuilder.InsertManyAsync<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 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 NamedId<Guid> appId = NamedId.Of(Guid.NewGuid(), "my-app");
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;
}
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>._))
.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 Squidex.Infrastructure;
using Squidex.Infrastructure.Queries;
using Squidex.Infrastructure.Tasks;
using Xunit;
using F = Squidex.Infrastructure.Queries.ClrFilter;
@ -75,7 +74,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.MongoDb
{
var time = SystemClock.Instance.GetCurrentInstant();
await _.ContentRepository.QueryScheduledWithoutDataAsync(time, _ => TaskHelper.Done);
await _.ContentRepository.QueryScheduledWithoutDataAsync(time, _ => Task.CompletedTask);
}
[Fact]

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
{
Task<IContentTextIndex> CreateAsync(Guid schemaId);
Task<ITextIndex> CreateAsync(Guid schemaId);
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);
}
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);
return new LuceneTextIndex(grainFactory);
return new LuceneTextIndex(grainFactory, indexManager);
}
public async Task CleanupAsync()

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Loading…
Cancel
Save