Browse Source

Resharper fix.

pull/462/head
Sebastian 6 years ago
parent
commit
7a31b13269
  1. 4
      backend/src/Squidex.Domain.Apps.Core.Model/Apps/Json/AppClientsConverter.cs
  2. 4
      backend/src/Squidex.Domain.Apps.Core.Model/Apps/Json/AppContributorsConverter.cs
  3. 4
      backend/src/Squidex.Domain.Apps.Core.Model/Apps/Json/AppPatternsConverter.cs
  4. 4
      backend/src/Squidex.Domain.Apps.Core.Model/Apps/Json/JsonLanguagesConfig.cs
  5. 14
      backend/src/Squidex.Domain.Apps.Core.Model/Contents/ContentData.cs
  6. 6
      backend/src/Squidex.Domain.Apps.Core.Model/Contents/Json/ContentFieldDataConverter.cs
  7. 4
      backend/src/Squidex.Domain.Apps.Core.Model/Contents/Json/WorkflowConverter.cs
  8. 4
      backend/src/Squidex.Domain.Apps.Core.Model/Contents/Workflow.cs
  9. 4
      backend/src/Squidex.Domain.Apps.Core.Model/Rules/Rule.cs
  10. 6
      backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/ContentConverter.cs
  11. 8
      backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/ContentConverterFlat.cs
  12. 24
      backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/FieldConverters.cs
  13. 10
      backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/ContentDataObject.cs
  14. 4
      backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/ContentDataProperty.cs
  15. 10
      backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/ContentFieldObject.cs
  16. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/ContentFieldProperty.cs
  17. 8
      backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/JsonMapper.cs
  18. 4
      backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs
  19. 2
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/FieldValidator.cs
  20. 12
      backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/ObjectValidator.cs
  21. 4
      backend/src/Squidex.Domain.Apps.Entities/Apps/AppGrain.cs
  22. 4
      backend/src/Squidex.Domain.Apps.Entities/Apps/AppUISettings.cs
  23. 2
      backend/src/Squidex.Domain.Apps.Entities/Apps/AppUISettingsGrain.cs
  24. 2
      backend/src/Squidex.Domain.Apps.Entities/Apps/DefaultAppImageStore.cs
  25. 2
      backend/src/Squidex.Domain.Apps.Entities/Apps/Guards/GuardAppClients.cs
  26. 8
      backend/src/Squidex.Domain.Apps.Entities/Apps/Guards/GuardAppWorkflows.cs
  27. 6
      backend/src/Squidex.Domain.Apps.Entities/Apps/Indexes/AppsIndex.cs
  28. 8
      backend/src/Squidex.Domain.Apps.Entities/Backup/BackupReader.cs
  29. 2
      backend/src/Squidex.Domain.Apps.Entities/Backup/DefaultBackupArchiveStore.cs
  30. 2
      backend/src/Squidex.Domain.Apps.Entities/Backup/RestoreGrain.cs
  31. 8
      backend/src/Squidex.Domain.Apps.Entities/Backup/UserMapping.cs
  32. 6
      backend/src/Squidex.Domain.Apps.Entities/Comments/CommentsGrain.cs
  33. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/ContentHistoryEventsCreator.cs
  34. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentDataFlatGraphType.cs
  35. 20
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentInterfaceGraphType.cs
  36. 4
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentUnionGraphType.cs
  37. 8
      backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/NestedGraphType.cs
  38. 16
      backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentEnricher.cs
  39. 14
      backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Extensions.cs
  40. 2
      backend/src/Squidex.Domain.Apps.Entities/Contents/Text/IndexManager_Impl.cs
  41. 4
      backend/src/Squidex.Domain.Apps.Entities/Contents/Text/TextIndexContent.cs
  42. 4
      backend/src/Squidex.Domain.Apps.Entities/Context.cs
  43. 4
      backend/src/Squidex.Domain.Apps.Entities/History/HistoryService.cs
  44. 4
      backend/src/Squidex.Domain.Apps.Entities/History/ParsedHistoryEvent.cs
  45. 2
      backend/src/Squidex.Domain.Apps.Entities/Rules/ManualTriggerHandler.cs
  46. 10
      backend/src/Squidex.Domain.Apps.Entities/Rules/UsageTracking/UsageTrackerGrain.cs
  47. 2
      backend/src/Squidex.Domain.Apps.Entities/Rules/UsageTracking/UsageTriggerHandler.cs
  48. 16
      backend/src/Squidex.Domain.Apps.Entities/Schemas/Guards/GuardSchema.cs
  49. 2
      backend/src/Squidex.Domain.Apps.Entities/Schemas/Guards/GuardSchemaField.cs
  50. 2
      backend/src/Squidex.Domain.Apps.Entities/Schemas/Indexes/SchemasIndex.cs
  51. 8
      backend/src/Squidex.Domain.Apps.Entities/Tags/TagGrain.cs
  52. 6
      backend/src/Squidex.Infrastructure.MongoDb/Assets/MongoGridFsAssetStore.cs
  53. 2
      backend/src/Squidex.Infrastructure.MongoDb/MongoDb/MongoExtensions.cs
  54. 2
      backend/src/Squidex.Infrastructure.MongoDb/MongoDb/MongoRepositoryBase.cs
  55. 8
      backend/src/Squidex.Infrastructure.MongoDb/MongoDb/Queries/SortBuilder.cs
  56. 4
      backend/src/Squidex.Infrastructure.MongoDb/UsageTracking/MongoUsageRepository.cs
  57. 8
      backend/src/Squidex.Infrastructure/CollectionExtensions.cs
  58. 6
      backend/src/Squidex.Infrastructure/Commands/DomainObjectGrain.cs
  59. 2
      backend/src/Squidex.Infrastructure/Commands/DomainObjectGrainBase.cs
  60. 8
      backend/src/Squidex.Infrastructure/Commands/LogSnapshotDomainObjectGrain.cs
  61. 6
      backend/src/Squidex.Infrastructure/Http/DumpFormatter.cs
  62. 6
      backend/src/Squidex.Infrastructure/Json/Newtonsoft/JsonValueConverter.cs
  63. 6
      backend/src/Squidex.Infrastructure/LanguagesInitializer.cs
  64. 10
      backend/src/Squidex.Infrastructure/Log/Adapter/SemanticLogLogger.cs
  65. 4
      backend/src/Squidex.Infrastructure/Log/ProfilerSession.cs
  66. 2
      backend/src/Squidex.Infrastructure/Migrations/Migrator.cs
  67. 8
      backend/src/Squidex.Infrastructure/Plugins/PluginManager.cs
  68. 2
      backend/src/Squidex.Infrastructure/Security/Permission.cs
  69. 10
      backend/src/Squidex.Infrastructure/UsageTracking/BackgroundUsageTracker.cs
  70. 7
      backend/src/Squidex.Infrastructure/Validation/AbsoluteUrlAttribute.cs
  71. 4
      backend/src/Squidex.Web/ApiPermissionAttribute.cs
  72. 6
      backend/src/Squidex.Web/ContextExtensions.cs
  73. 6
      backend/src/Squidex.Web/ExposedValues.cs
  74. 4
      backend/src/Squidex.Web/Pipeline/ActionContextLogAppender.cs
  75. 1
      backend/src/Squidex/Areas/Api/Controllers/Assets/Models/AssetFolderDto.cs
  76. 4
      backend/src/Squidex/Areas/Api/Controllers/Contents/Models/ContentsDto.cs
  77. 2
      backend/src/Squidex/Areas/Frontend/Middlewares/IndexExtensions.cs
  78. 2
      backend/src/Squidex/Areas/Frontend/Middlewares/IndexMiddleware.cs
  79. 2
      backend/src/Squidex/Areas/IdentityServer/Views/Profile/Profile.cshtml
  80. 2
      backend/src/Squidex/Config/Authentication/GoogleHandler.cs
  81. 2
      backend/src/Squidex/Config/Domain/ConfigurationExtensions.cs
  82. 2
      backend/src/Squidex/Config/Domain/ContentsServices.cs
  83. 2
      backend/src/Squidex/Config/Domain/QueryServices.cs
  84. 1
      backend/src/Squidex/Config/Orleans/OrleansServices.cs
  85. 10
      backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Apps/RolesTests.cs
  86. 9
      backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/EventSynchronization/SchemaSynchronizerTests.cs
  87. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/BackupAppsTests.cs
  88. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Indexes/AppsIndexTests.cs
  89. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Guards/GuardAssetFolderTests.cs
  90. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Guards/GuardAssetTests.cs
  91. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/AssetQueryServiceTests.cs
  92. 6
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Backup/BackupReaderWriterTests.cs
  93. 2
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Backup/UserMappingTests.cs
  94. 8
      backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Guard/GuardContentTests.cs
  95. 7
      backend/tests/Squidex.Domain.Apps.Entities.Tests/TestHelpers/AExtensions.cs
  96. 4
      backend/tests/Squidex.Infrastructure.Tests/Log/SemanticLogTests.cs
  97. 2
      backend/tests/Squidex.Web.Tests/Pipeline/EnforceHttpsMiddlewareTests.cs
  98. 12
      backend/tools/Migrate_01/Migrations/PopulateGrainIndexes.cs

4
backend/src/Squidex.Domain.Apps.Core.Model/Apps/Json/AppClientsConverter.cs

@ -19,9 +19,9 @@ namespace Squidex.Domain.Apps.Core.Apps.Json
{ {
var json = new Dictionary<string, JsonAppClient>(value.Count); var json = new Dictionary<string, JsonAppClient>(value.Count);
foreach (var client in value) foreach (var (key, appClient) in value)
{ {
json.Add(client.Key, new JsonAppClient(client.Value)); json.Add(key, new JsonAppClient(appClient));
} }
serializer.Serialize(writer, json); serializer.Serialize(writer, json);

4
backend/src/Squidex.Domain.Apps.Core.Model/Apps/Json/AppContributorsConverter.cs

@ -19,9 +19,9 @@ namespace Squidex.Domain.Apps.Core.Apps.Json
{ {
var json = new Dictionary<string, string>(value.Count); var json = new Dictionary<string, string>(value.Count);
foreach (var contributor in value) foreach (var (userId, role) in value)
{ {
json.Add(contributor.Key, contributor.Value); json.Add(userId, role);
} }
serializer.Serialize(writer, json); serializer.Serialize(writer, json);

4
backend/src/Squidex.Domain.Apps.Core.Model/Apps/Json/AppPatternsConverter.cs

@ -19,9 +19,9 @@ namespace Squidex.Domain.Apps.Core.Apps.Json
{ {
var json = new Dictionary<Guid, JsonAppPattern>(value.Count); var json = new Dictionary<Guid, JsonAppPattern>(value.Count);
foreach (var client in value) foreach (var (key, appPattern) in value)
{ {
json.Add(client.Key, new JsonAppPattern(client.Value)); json.Add(key, new JsonAppPattern(appPattern));
} }
serializer.Serialize(writer, json); serializer.Serialize(writer, json);

4
backend/src/Squidex.Domain.Apps.Core.Model/Apps/Json/JsonLanguagesConfig.cs

@ -43,9 +43,9 @@ namespace Squidex.Domain.Apps.Core.Apps.Json
{ {
var i = 0; var i = 0;
foreach (var config in Languages) foreach (var (key, value) in Languages)
{ {
languagesConfig[i++] = config.Value.ToConfig(config.Key); languagesConfig[i++] = value.ToConfig(key);
} }
} }

14
backend/src/Squidex.Domain.Apps.Core.Model/Contents/ContentData.cs

@ -41,17 +41,17 @@ namespace Squidex.Domain.Apps.Core.Contents
foreach (var source in sources) foreach (var source in sources)
{ {
foreach (var otherValue in source) foreach (var (key, contentFieldData) in source)
{ {
if (otherValue.Value != null) if (contentFieldData != null)
{ {
var fieldValue = target.GetOrAdd(otherValue.Key, x => new ContentFieldData()); var fieldValue = target.GetOrAdd(key, x => new ContentFieldData());
if (fieldValue != null) if (fieldValue != null)
{ {
foreach (var value in otherValue.Value) foreach (var (fieldName, value) in contentFieldData)
{ {
fieldValue[value.Key] = value.Value; fieldValue[fieldName] = value;
} }
} }
} }
@ -67,9 +67,9 @@ namespace Squidex.Domain.Apps.Core.Contents
{ {
var resultValue = new ContentFieldData(); var resultValue = new ContentFieldData();
foreach (var partitionValue in fieldValue.Value.Where(x => x.Value.Type != JsonValueType.Null)) foreach (var (key, value) in fieldValue.Value.Where(x => x.Value.Type != JsonValueType.Null))
{ {
resultValue[partitionValue.Key] = partitionValue.Value; resultValue[key] = value;
} }
if (resultValue.Count > 0) if (resultValue.Count > 0)

6
backend/src/Squidex.Domain.Apps.Core.Model/Contents/Json/ContentFieldDataConverter.cs

@ -19,11 +19,11 @@ namespace Squidex.Domain.Apps.Core.Contents.Json
{ {
writer.WriteStartObject(); writer.WriteStartObject();
foreach (var kvp in value) foreach (var (key, jsonValue) in value)
{ {
writer.WritePropertyName(kvp.Key); writer.WritePropertyName(key);
serializer.Serialize(writer, kvp.Value); serializer.Serialize(writer, jsonValue);
} }
writer.WriteEndObject(); writer.WriteEndObject();

4
backend/src/Squidex.Domain.Apps.Core.Model/Contents/Json/WorkflowConverter.cs

@ -19,9 +19,9 @@ namespace Squidex.Domain.Apps.Core.Contents.Json
{ {
var json = new Dictionary<Guid, Workflow>(value.Count); var json = new Dictionary<Guid, Workflow>(value.Count);
foreach (var workflow in value) foreach (var (key, workflow) in value)
{ {
json.Add(workflow.Key, workflow.Value); json.Add(key, workflow);
} }
serializer.Serialize(writer, json); serializer.Serialize(writer, json);

4
backend/src/Squidex.Domain.Apps.Core.Model/Contents/Workflow.cs

@ -81,9 +81,9 @@ namespace Squidex.Domain.Apps.Core.Contents
{ {
if (TryGetStep(status, out var step)) if (TryGetStep(status, out var step))
{ {
foreach (var transition in step.Transitions) foreach (var (nextStatus, transition) in step.Transitions)
{ {
yield return (transition.Key, Steps[transition.Key], transition.Value); yield return (nextStatus, Steps[nextStatus], transition);
} }
} }
else if (TryGetStep(Initial, out var initial)) else if (TryGetStep(Initial, out var initial))

4
backend/src/Squidex.Domain.Apps.Core.Model/Rules/Rule.cs

@ -51,11 +51,11 @@ namespace Squidex.Domain.Apps.Core.Rules
} }
[Pure] [Pure]
public Rule Rename(string name) public Rule Rename(string newName)
{ {
return Clone(clone => return Clone(clone =>
{ {
clone.name = name; clone.name = newName;
}); });
} }

6
backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/ContentConverter.cs

@ -123,14 +123,14 @@ namespace Squidex.Domain.Apps.Core.ConvertContent
where TKey1 : notnull where TKey1 : notnull
where TKey2 : notnull where TKey2 : notnull
{ {
foreach (var fieldKvp in source) foreach (var (fieldName, value) in source)
{ {
if (!fields.TryGetValue(fieldKvp.Key, out var field)) if (!fields.TryGetValue(fieldName, out var field))
{ {
continue; continue;
} }
ContentFieldData? newValue = fieldKvp.Value; var newValue = value;
if (newValue != null) if (newValue != null)
{ {

8
backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/ContentConverterFlat.cs

@ -18,9 +18,9 @@ namespace Squidex.Domain.Apps.Core.ConvertContent
{ {
var result = new Dictionary<string, object?>(); var result = new Dictionary<string, object?>();
foreach (var fieldValue in content) foreach (var (key, value) in content)
{ {
result[fieldValue.Key] = GetFirst(fieldValue.Value); result[key] = GetFirst(value);
} }
return result; return result;
@ -30,9 +30,9 @@ namespace Squidex.Domain.Apps.Core.ConvertContent
{ {
var result = new FlatContentData(); var result = new FlatContentData();
foreach (var fieldValue in content) foreach (var (key, value) in content)
{ {
result[fieldValue.Key] = GetFirst(fieldValue.Value, fallback); result[key] = GetFirst(value, fallback);
} }
return result; return result;

24
backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/FieldConverters.cs

@ -141,11 +141,11 @@ namespace Squidex.Domain.Apps.Core.ConvertContent
{ {
if (array[i] is JsonObject arrayItem) if (array[i] is JsonObject arrayItem)
{ {
foreach (var kvp in arrayItem) foreach (var (key, value) in arrayItem)
{ {
if (arrayField.FieldsByName.TryGetValue(kvp.Key, out var nestedField) && ShouldHandle(nestedField, field)) if (arrayField.FieldsByName.TryGetValue(key, out var nestedField) && ShouldHandle(nestedField, field))
{ {
Resolve(kvp.Value); Resolve(value);
} }
} }
} }
@ -332,9 +332,9 @@ namespace Squidex.Domain.Apps.Core.ConvertContent
{ {
var result = new ContentFieldData(); var result = new ContentFieldData();
foreach (var partition in data) foreach (var (partitionKey, partitionValue) in data)
{ {
if (!(partition.Value is JsonArray array)) if (!(partitionValue is JsonArray array))
{ {
continue; continue;
} }
@ -345,16 +345,16 @@ namespace Squidex.Domain.Apps.Core.ConvertContent
{ {
var newItem = JsonValue.Object(); var newItem = JsonValue.Object();
foreach (var kvp in item) foreach (var (key, value) in item)
{ {
var nestedField = fieldResolver(arrayField, kvp.Key); var nestedField = fieldResolver(arrayField, key);
if (nestedField == null) if (nestedField == null)
{ {
continue; continue;
} }
var newValue = kvp.Value; var newValue = value;
var isUnset = false; var isUnset = false;
@ -381,7 +381,7 @@ namespace Squidex.Domain.Apps.Core.ConvertContent
newArray.Add(newItem); newArray.Add(newItem);
} }
result.Add(partition.Key, newArray); result.Add(partitionKey, newArray);
} }
return result; return result;
@ -399,9 +399,9 @@ namespace Squidex.Domain.Apps.Core.ConvertContent
{ {
var result = new ContentFieldData(); var result = new ContentFieldData();
foreach (var partition in data) foreach (var (key, value) in data)
{ {
var newValue = partition.Value; var newValue = value;
var isUnset = false; var isUnset = false;
@ -421,7 +421,7 @@ namespace Squidex.Domain.Apps.Core.ConvertContent
if (!isUnset) if (!isUnset)
{ {
result.Add(partition.Key, newValue); result.Add(key, newValue);
} }
} }

10
backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/ContentDataObject.cs

@ -53,13 +53,13 @@ namespace Squidex.Domain.Apps.Core.Scripting.ContentWrapper
if (fieldProperties != null) if (fieldProperties != null)
{ {
foreach (var kvp in fieldProperties) foreach (var (key, propertyDescriptor) in fieldProperties)
{ {
var value = (ContentDataProperty)kvp.Value; var value = (ContentDataProperty)propertyDescriptor;
if (value.ContentField != null && value.ContentField.TryUpdate(out var fieldData)) if (value.ContentField != null && value.ContentField.TryUpdate(out var fieldData))
{ {
contentData[kvp.Key] = fieldData; contentData[key] = fieldData;
} }
} }
} }
@ -120,9 +120,9 @@ namespace Squidex.Domain.Apps.Core.Scripting.ContentWrapper
{ {
fieldProperties = new Dictionary<string, PropertyDescriptor>(contentData.Count); fieldProperties = new Dictionary<string, PropertyDescriptor>(contentData.Count);
foreach (var kvp in contentData) foreach (var (key, value) in contentData)
{ {
fieldProperties.Add(kvp.Key, new ContentDataProperty(this, new ContentFieldObject(this, kvp.Value, false))); fieldProperties.Add(key, new ContentDataProperty(this, new ContentFieldObject(this, value, false)));
} }
} }
} }

4
backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/ContentDataProperty.cs

@ -36,9 +36,9 @@ namespace Squidex.Domain.Apps.Core.Scripting.ContentWrapper
contentField = new ContentFieldObject(contentData, new ContentFieldData(), true); contentField = new ContentFieldObject(contentData, new ContentFieldData(), true);
foreach (var kvp in obj.GetOwnProperties()) foreach (var (key, propertyDescriptor) in obj.GetOwnProperties())
{ {
contentField.Put(kvp.Key, kvp.Value.Value, true); contentField.Put(key, propertyDescriptor.Value, true);
} }
this.value = contentField; this.value = contentField;

10
backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/ContentFieldObject.cs

@ -65,13 +65,13 @@ namespace Squidex.Domain.Apps.Core.Scripting.ContentWrapper
if (valueProperties != null) if (valueProperties != null)
{ {
foreach (var kvp in valueProperties) foreach (var (key, propertyDescriptor) in valueProperties)
{ {
var value = (ContentFieldProperty)kvp.Value; var value = (ContentFieldProperty)propertyDescriptor;
if (value.IsChanged) if (value.IsChanged)
{ {
fieldData[kvp.Key] = value.ContentValue; fieldData[key] = value.ContentValue;
} }
} }
} }
@ -127,9 +127,9 @@ namespace Squidex.Domain.Apps.Core.Scripting.ContentWrapper
if (fieldData != null) if (fieldData != null)
{ {
foreach (var kvp in fieldData) foreach (var (key, value) in fieldData)
{ {
valueProperties.Add(kvp.Key, new ContentFieldProperty(this, kvp.Value)); valueProperties.Add(key, new ContentFieldProperty(this, value));
} }
} }
} }

2
backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/ContentFieldProperty.cs

@ -47,7 +47,7 @@ namespace Squidex.Domain.Apps.Core.Scripting.ContentWrapper
public IJsonValue ContentValue public IJsonValue ContentValue
{ {
get { return contentValue ?? (contentValue = JsonMapper.Map(value)); } get { return contentValue ??= JsonMapper.Map(value); }
} }
public bool IsChanged public bool IsChanged

8
backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/JsonMapper.cs

@ -57,9 +57,9 @@ namespace Squidex.Domain.Apps.Core.Scripting.ContentWrapper
{ {
var target = new ObjectInstance(engine); var target = new ObjectInstance(engine);
foreach (var property in obj) foreach (var (key, value) in obj)
{ {
target.FastAddProperty(property.Key, Map(property.Value, engine), false, true, true); target.FastAddProperty(key, Map(value, engine), false, true, true);
} }
return target; return target;
@ -117,9 +117,9 @@ namespace Squidex.Domain.Apps.Core.Scripting.ContentWrapper
var result = JsonValue.Object(); var result = JsonValue.Object();
foreach (var kvp in obj.GetOwnProperties()) foreach (var (key, propertyDescriptor) in obj.GetOwnProperties())
{ {
result[kvp.Key] = Map(kvp.Value.Value); result[key] = Map(propertyDescriptor.Value);
} }
return result; return result;

4
backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs

@ -186,9 +186,9 @@ namespace Squidex.Domain.Apps.Core.Scripting
if (customFormatters != null) if (customFormatters != null)
{ {
foreach (var kvp in customFormatters) foreach (var (key, value) in customFormatters)
{ {
engine.SetValue(kvp.Key, Safe(kvp.Value)); engine.SetValue(key, Safe(value));
} }
} }

2
backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/FieldValidator.cs

@ -32,7 +32,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
{ {
try try
{ {
object? typedValue = value; var typedValue = value;
if (value is IJsonValue jsonValue) if (value is IJsonValue jsonValue)
{ {

12
backend/src/Squidex.Domain.Apps.Core.Operations/ValidateContent/Validators/ObjectValidator.cs

@ -45,15 +45,13 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
var tasks = new List<Task>(); var tasks = new List<Task>();
foreach (var field in schema) foreach (var (fieldName, fieldConfig) in schema)
{ {
var name = field.Key; var (isOptional, validator) = fieldConfig;
var (isOptional, validator) = field.Value; var fieldValue = Undefined.Value;
object? fieldValue = Undefined.Value; if (!values.TryGetValue(fieldName, out var temp))
if (!values.TryGetValue(name, out var temp))
{ {
if (isPartial) if (isPartial)
{ {
@ -65,7 +63,7 @@ namespace Squidex.Domain.Apps.Core.ValidateContent.Validators
fieldValue = temp; fieldValue = temp;
} }
var fieldContext = context.Nested(name).Optional(isOptional); var fieldContext = context.Nested(fieldName).Optional(isOptional);
tasks.Add(validator.ValidateAsync(fieldValue, fieldContext, addError)); tasks.Add(validator.ValidateAsync(fieldValue, fieldContext, addError));
} }

4
backend/src/Squidex.Domain.Apps.Entities/Apps/AppGrain.cs

@ -327,9 +327,9 @@ namespace Squidex.Domain.Apps.Entities.Apps
CreateInitialLanguage() CreateInitialLanguage()
}; };
foreach (var pattern in initialPatterns) foreach (var (key, value) in initialPatterns)
{ {
events.Add(CreateInitialPattern(pattern.Key, pattern.Value)); events.Add(CreateInitialPattern(key, value));
} }
foreach (var @event in events) foreach (var @event in events)

4
backend/src/Squidex.Domain.Apps.Entities/Apps/AppUISettings.cs

@ -49,10 +49,10 @@ namespace Squidex.Domain.Apps.Entities.Apps
private IAppUISettingsGrain GetGrain(Guid appId, string? userId) private IAppUISettingsGrain GetGrain(Guid appId, string? userId)
{ {
return grainFactory.GetGrain<IAppUISettingsGrain>(Key(appId, userId)); return grainFactory.GetGrain<IAppUISettingsGrain>(GetKey(appId, userId));
} }
private string Key(Guid appId, string? userId) private static string GetKey(Guid appId, string? userId)
{ {
if (!string.IsNullOrWhiteSpace(userId)) if (!string.IsNullOrWhiteSpace(userId))
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Apps/AppUISettingsGrain.cs

@ -76,7 +76,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
var segments = path.Split('.'); var segments = path.Split('.');
key = segments[segments.Length - 1]; key = segments[^1];
var current = state.Value.Settings; var current = state.Value.Settings;

2
backend/src/Squidex.Domain.Apps.Entities/Apps/DefaultAppImageStore.cs

@ -39,7 +39,7 @@ namespace Squidex.Domain.Apps.Entities.Apps
return assetStore.UploadAsync(fileName, stream, true, ct); return assetStore.UploadAsync(fileName, stream, true, ct);
} }
private string GetFileName(Guid backupId) private static string GetFileName(Guid backupId)
{ {
return backupId.ToString(); return backupId.ToString();
} }

2
backend/src/Squidex.Domain.Apps.Entities/Apps/Guards/GuardAppClients.cs

@ -50,7 +50,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Guards
{ {
Guard.NotNull(command); Guard.NotNull(command);
var client = GetClientOrThrow(clients, command.Id); GetClientOrThrow(clients, command.Id);
Validate.It(() => "Cannot update client.", e => Validate.It(() => "Cannot update client.", e =>
{ {

8
backend/src/Squidex.Domain.Apps.Entities/Apps/Guards/GuardAppWorkflows.cs

@ -71,16 +71,16 @@ namespace Squidex.Domain.Apps.Entities.Apps.Guards
} }
else else
{ {
foreach (var transition in step.Value.Transitions) foreach (var (status, transition) in step.Value.Transitions)
{ {
var transitionPrefix = $"{stepPrefix}.{nameof(step.Value.Transitions)}.{transition.Key}"; var transitionPrefix = $"{stepPrefix}.{nameof(step.Value.Transitions)}.{status}";
if (!workflow.Steps.ContainsKey(transition.Key)) if (!workflow.Steps.ContainsKey(status))
{ {
e("Transition has an invalid target.", transitionPrefix); e("Transition has an invalid target.", transitionPrefix);
} }
if (transition.Value == null) if (transition == null)
{ {
e(Not.Defined("Transition"), transitionPrefix); e(Not.Defined("Transition"), transitionPrefix);
} }

6
backend/src/Squidex.Domain.Apps.Entities/Apps/Indexes/AppsIndex.cs

@ -78,7 +78,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes
var apps = var apps =
await Task.WhenAll(ids await Task.WhenAll(ids
.Select(id => GetAppAsync(id))); .Select(GetAppAsync));
return apps.Where(x => x != null).ToList(); return apps.Where(x => x != null).ToList();
} }
@ -96,7 +96,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes
var apps = var apps =
await Task.WhenAll(ids await Task.WhenAll(ids
.SelectMany(x => x) .SelectMany(x => x)
.Select(id => GetAppAsync(id))); .Select(GetAppAsync));
return apps.Where(x => x != null).ToList(); return apps.Where(x => x != null).ToList();
} }
@ -217,7 +217,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes
} }
} }
private async Task<string?> CheckAppAsync(IAppsByNameIndexGrain index, CreateApp command) private static async Task<string?> CheckAppAsync(IAppsByNameIndexGrain index, CreateApp command)
{ {
var name = command.Name; var name = command.Name;

8
backend/src/Squidex.Domain.Apps.Entities/Backup/BackupReader.cs

@ -138,15 +138,15 @@ namespace Squidex.Domain.Apps.Entities.Backup
private void MapHeaders(EventData data) private void MapHeaders(EventData data)
{ {
foreach (var kvp in data.Headers.ToList()) foreach (var (key, value) in data.Headers.ToList())
{ {
if (kvp.Value.Type == JsonValueType.String) if (value.Type == JsonValueType.String)
{ {
var newGuid = guidMapper.NewGuidOrNull(kvp.Value.ToString()); var newGuid = guidMapper.NewGuidOrNull(value.ToString());
if (newGuid != null) if (newGuid != null)
{ {
data.Headers.Add(kvp.Key, newGuid); data.Headers.Add(key, newGuid);
} }
} }
} }

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

@ -46,7 +46,7 @@ namespace Squidex.Domain.Apps.Entities.Backup
return assetStore.DeleteAsync(fileName); return assetStore.DeleteAsync(fileName);
} }
private string GetFileName(Guid backupId) private static string GetFileName(Guid backupId)
{ {
return $"{backupId}_0"; return $"{backupId}_0";
} }

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

@ -378,7 +378,7 @@ namespace Squidex.Domain.Apps.Entities.Backup
{ {
if (replace && CurrentJob.Log.Count > 0) if (replace && CurrentJob.Log.Count > 0)
{ {
CurrentJob.Log[CurrentJob.Log.Count - 1] = $"{clock.GetCurrentInstant()}: {message}"; CurrentJob.Log[^1] = $"{clock.GetCurrentInstant()}: {message}";
} }
else else
{ {

8
backend/src/Squidex.Domain.Apps.Entities/Backup/UserMapping.cs

@ -72,20 +72,18 @@ namespace Squidex.Domain.Apps.Entities.Backup
var json = await reader.ReadJsonAttachmentAsync<Dictionary<string, string>>(UsersFile); var json = await reader.ReadJsonAttachmentAsync<Dictionary<string, string>>(UsersFile);
foreach (var kvp in json) foreach (var (userId, email) in json)
{ {
var email = kvp.Value;
var user = await userResolver.FindByIdOrEmailAsync(email); var user = await userResolver.FindByIdOrEmailAsync(email);
if (user == null && await userResolver.CreateUserIfNotExistsAsync(kvp.Value, false)) if (user == null && await userResolver.CreateUserIfNotExistsAsync(email, false))
{ {
user = await userResolver.FindByIdOrEmailAsync(email); user = await userResolver.FindByIdOrEmailAsync(email);
} }
if (user != null) if (user != null)
{ {
userMap[kvp.Key] = new RefToken(RefTokenType.Subject, user.Id); userMap[userId] = new RefToken(RefTokenType.Subject, user.Id);
} }
} }
} }

6
backend/src/Squidex.Domain.Apps.Entities/Comments/CommentsGrain.cs

@ -60,11 +60,11 @@ namespace Squidex.Domain.Apps.Entities.Comments
return persistence.ReadAsync(); return persistence.ReadAsync();
} }
protected override async Task WriteAsync(Envelope<IEvent>[] events, long previousVersion) protected override async Task WriteAsync(Envelope<IEvent>[] newEvents, long previousVersion)
{ {
if (events.Length > 0) if (newEvents.Length > 0)
{ {
await persistence.WriteEventsAsync(events); await persistence.WriteEventsAsync(newEvents);
} }
} }

2
backend/src/Squidex.Domain.Apps.Entities/Contents/ContentHistoryEventsCreator.cs

@ -68,7 +68,7 @@ namespace Squidex.Domain.Apps.Entities.Contents
result = result.Param("Status", contentStatusScheduled.Status); result = result.Param("Status", contentStatusScheduled.Status);
} }
return Task.FromResult<HistoryEvent?>(result); return Task.FromResult(result);
} }
} }
} }

2
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentDataFlatGraphType.cs

@ -18,7 +18,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types
{ {
Name = $"{schemaType}DataFlatDto"; Name = $"{schemaType}DataFlatDto";
foreach (var (field, fieldName, typeName) in schema.SchemaDef.Fields.SafeFields()) foreach (var (field, fieldName, _) in schema.SchemaDef.Fields.SafeFields())
{ {
var (resolvedType, valueResolver) = model.GetGraphType(schema, field, fieldName); var (resolvedType, valueResolver) = model.GetGraphType(schema, field, fieldName);

20
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentInterfaceGraphType.cs

@ -15,14 +15,14 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types
{ {
public ContentInterfaceGraphType() public ContentInterfaceGraphType()
{ {
Name = $"Content"; Name = "Content";
AddField(new FieldType AddField(new FieldType
{ {
Name = "id", Name = "id",
ResolvedType = AllTypes.NonNullGuid, ResolvedType = AllTypes.NonNullGuid,
Resolver = Resolve(x => x.Id), Resolver = Resolve(x => x.Id),
Description = $"The id of the content." Description = "The id of the content."
}); });
AddField(new FieldType AddField(new FieldType
@ -30,7 +30,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types
Name = "version", Name = "version",
ResolvedType = AllTypes.NonNullInt, ResolvedType = AllTypes.NonNullInt,
Resolver = Resolve(x => x.Version), Resolver = Resolve(x => x.Version),
Description = $"The version of the content." Description = "The version of the content."
}); });
AddField(new FieldType AddField(new FieldType
@ -38,7 +38,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types
Name = "created", Name = "created",
ResolvedType = AllTypes.NonNullDate, ResolvedType = AllTypes.NonNullDate,
Resolver = Resolve(x => x.Created), Resolver = Resolve(x => x.Created),
Description = $"The date and time when the content has been created." Description = "The date and time when the content has been created."
}); });
AddField(new FieldType AddField(new FieldType
@ -46,7 +46,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types
Name = "createdBy", Name = "createdBy",
ResolvedType = AllTypes.NonNullString, ResolvedType = AllTypes.NonNullString,
Resolver = Resolve(x => x.CreatedBy.ToString()), Resolver = Resolve(x => x.CreatedBy.ToString()),
Description = $"The user that has created the content." Description = "The user that has created the content."
}); });
AddField(new FieldType AddField(new FieldType
@ -54,7 +54,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types
Name = "lastModified", Name = "lastModified",
ResolvedType = AllTypes.NonNullDate, ResolvedType = AllTypes.NonNullDate,
Resolver = Resolve(x => x.LastModified), Resolver = Resolve(x => x.LastModified),
Description = $"The date and time when the content has been modified last." Description = "The date and time when the content has been modified last."
}); });
AddField(new FieldType AddField(new FieldType
@ -62,7 +62,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types
Name = "lastModifiedBy", Name = "lastModifiedBy",
ResolvedType = AllTypes.NonNullString, ResolvedType = AllTypes.NonNullString,
Resolver = Resolve(x => x.LastModifiedBy.ToString()), Resolver = Resolve(x => x.LastModifiedBy.ToString()),
Description = $"The user that has updated the content last." Description = "The user that has updated the content last."
}); });
AddField(new FieldType AddField(new FieldType
@ -70,7 +70,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types
Name = "status", Name = "status",
ResolvedType = AllTypes.NonNullString, ResolvedType = AllTypes.NonNullString,
Resolver = Resolve(x => x.Status.Name.ToUpperInvariant()), Resolver = Resolve(x => x.Status.Name.ToUpperInvariant()),
Description = $"The the status of the content." Description = "The the status of the content."
}); });
AddField(new FieldType AddField(new FieldType
@ -78,10 +78,10 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types
Name = "statusColor", Name = "statusColor",
ResolvedType = AllTypes.NonNullString, ResolvedType = AllTypes.NonNullString,
Resolver = Resolve(x => x.StatusColor), Resolver = Resolve(x => x.StatusColor),
Description = $"The color status of the content." Description = "The color status of the content."
}); });
Description = $"The structure of all content types."; Description = "The structure of all content types.";
} }
private static IFieldResolver Resolve(Func<IEnrichedContentEntity, object> action) private static IFieldResolver Resolve(Func<IEnrichedContentEntity, object> action)

4
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/ContentUnionGraphType.cs

@ -35,9 +35,9 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types
} }
else else
{ {
foreach (var schemaType in schemaTypes) foreach (var (key, value) in schemaTypes)
{ {
types[schemaType.Key] = schemaType.Value; types[key] = value;
} }
} }

8
backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/NestedGraphType.cs

@ -26,17 +26,17 @@ namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types
foreach (var (nestedField, nestedName, _) in field.Fields.SafeFields()) foreach (var (nestedField, nestedName, _) in field.Fields.SafeFields())
{ {
var fieldInfo = model.GetGraphType(schema, nestedField, nestedName); var (resolveType, valueResolver) = model.GetGraphType(schema, nestedField, nestedName);
if (fieldInfo.ResolveType != null && fieldInfo.Resolver != null) if (resolveType != null && valueResolver != null)
{ {
var resolver = ValueResolver(nestedField, fieldInfo.Resolver); var resolver = ValueResolver(nestedField, valueResolver);
AddField(new FieldType AddField(new FieldType
{ {
Name = nestedName, Name = nestedName,
Resolver = resolver, Resolver = resolver,
ResolvedType = fieldInfo.ResolveType, ResolvedType = resolveType,
Description = $"The {fieldDisplayName}/{nestedField.DisplayName()} nested field." Description = $"The {fieldDisplayName}/{nestedField.DisplayName()} nested field."
}); });
} }

16
backend/src/Squidex.Domain.Apps.Entities/Contents/Queries/ContentEnricher.cs

@ -70,8 +70,6 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries
if (contents.Any()) if (contents.Any())
{ {
var appVersion = context.App.Version;
var cache = new Dictionary<(Guid, Status), StatusInfo>(); var cache = new Dictionary<(Guid, Status), StatusInfo>();
foreach (var content in contents) foreach (var content in contents)
@ -190,10 +188,10 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries
{ {
if (content.DataDraft.TryGetValue(field.Name, out var fieldData) && fieldData != null) if (content.DataDraft.TryGetValue(field.Name, out var fieldData) && fieldData != null)
{ {
foreach (var partitionValue in fieldData) foreach (var (partition, partitionValue) in fieldData)
{ {
var referencedContents = var referencedContents =
field.GetReferencedIds(partitionValue.Value, Ids.ContentOnly) field.GetReferencedIds(partitionValue, Ids.ContentOnly)
.Select(x => references[x]) .Select(x => references[x])
.SelectMany(x => x) .SelectMany(x => x)
.ToList(); .ToList();
@ -211,13 +209,13 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries
var value = formatted.GetOrAdd(reference, x => Format(x, context, referencedSchema)); var value = formatted.GetOrAdd(reference, x => Format(x, context, referencedSchema));
fieldReference.AddJsonValue(partitionValue.Key, value); fieldReference.AddJsonValue(partition, value);
} }
else if (referencedContents.Count > 1) else if (referencedContents.Count > 1)
{ {
var value = CreateFallback(context, referencedContents); var value = CreateFallback(context, referencedContents);
fieldReference.AddJsonValue(partitionValue.Key, value); fieldReference.AddJsonValue(partition, value);
} }
} }
} }
@ -245,10 +243,10 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries
if (content.DataDraft.TryGetValue(field.Name, out var fieldData) && fieldData != null) if (content.DataDraft.TryGetValue(field.Name, out var fieldData) && fieldData != null)
{ {
foreach (var partitionValue in fieldData) foreach (var (partitionKey, partitionValue) in fieldData)
{ {
var referencedImage = var referencedImage =
field.GetReferencedIds(partitionValue.Value, Ids.ContentOnly) field.GetReferencedIds(partitionValue, Ids.ContentOnly)
.Select(x => assets[x]) .Select(x => assets[x])
.SelectMany(x => x) .SelectMany(x => x)
.FirstOrDefault(x => x.IsImage); .FirstOrDefault(x => x.IsImage);
@ -260,7 +258,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Queries
content.CacheDependencies.Add(referencedImage.Id); content.CacheDependencies.Add(referencedImage.Id);
content.CacheDependencies.Add(referencedImage.Version); content.CacheDependencies.Add(referencedImage.Version);
fieldReference.AddJsonValue(partitionValue.Key, JsonValue.Create(url)); fieldReference.AddJsonValue(partitionKey, JsonValue.Create(url));
} }
} }
} }

14
backend/src/Squidex.Domain.Apps.Entities/Contents/Text/Extensions.cs

@ -56,22 +56,22 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text
} }
} }
foreach (var field in data) foreach (var value in data.Values)
{ {
if (field.Value != null) if (value != null)
{ {
foreach (var fieldValue in field.Value) foreach (var (key, jsonValue) in value)
{ {
var appendText = new Action<string>(text => AppendText(fieldValue.Key, text)); var appendText = new Action<string>(text => AppendText(key, text));
AppendJsonText(fieldValue.Value, appendText); AppendJsonText(jsonValue, appendText);
} }
} }
} }
foreach (var kvp in languages) foreach (var (key, value) in languages)
{ {
result[kvp.Key] = kvp.Value.ToString(); result[key] = value.ToString();
} }
} }

2
backend/src/Squidex.Domain.Apps.Entities/Contents/Text/IndexManager_Impl.cs

@ -154,7 +154,7 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text
} }
} }
internal void ThrowIfReleased() private void ThrowIfReleased()
{ {
if (isReleased) if (isReleased)
{ {

4
backend/src/Squidex.Domain.Apps.Entities/Contents/Text/TextIndexContent.cs

@ -123,9 +123,9 @@ namespace Squidex.Domain.Apps.Entities.Contents.Text
{ {
var document = new Document(); var document = new Document();
foreach (var field in text) foreach (var (key, value) in text)
{ {
document.AddTextField(field.Key, field.Value, Field.Store.NO); document.AddTextField(key, value, Field.Store.NO);
} }
return document; return document;

4
backend/src/Squidex.Domain.Apps.Entities/Context.cs

@ -60,9 +60,9 @@ namespace Squidex.Domain.Apps.Entities
{ {
var clone = new Context(User, App); var clone = new Context(User, App);
foreach (var kvp in Headers) foreach (var (key, value) in Headers)
{ {
clone.Headers[kvp.Key] = kvp.Value; clone.Headers[key] = value;
} }
return clone; return clone;

4
backend/src/Squidex.Domain.Apps.Entities/History/HistoryService.cs

@ -41,9 +41,9 @@ namespace Squidex.Domain.Apps.Entities.History
foreach (var creator in this.creators) foreach (var creator in this.creators)
{ {
foreach (var text in creator.Texts) foreach (var (key, value) in creator.Texts)
{ {
texts[text.Key] = text.Value; texts[key] = value;
} }
} }

4
backend/src/Squidex.Domain.Apps.Entities/History/ParsedHistoryEvent.cs

@ -55,9 +55,9 @@ namespace Squidex.Domain.Apps.Entities.History
{ {
if (texts.TryGetValue(item.Message, out var result)) if (texts.TryGetValue(item.Message, out var result))
{ {
foreach (var kvp in item.Parameters) foreach (var (key, value) in item.Parameters)
{ {
result = result.Replace("[" + kvp.Key + "]", kvp.Value); result = result.Replace("[" + key + "]", value);
} }
return result; return result;

2
backend/src/Squidex.Domain.Apps.Entities/Rules/ManualTriggerHandler.cs

@ -23,7 +23,7 @@ namespace Squidex.Domain.Apps.Entities.Rules
Name = "Manual" Name = "Manual"
}; };
return Task.FromResult<EnrichedManualEvent?>(result); return Task.FromResult(result);
} }
protected override bool Trigger(EnrichedManualEvent @event, ManualTrigger trigger) protected override bool Trigger(EnrichedManualEvent @event, ManualTrigger trigger)

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

@ -78,28 +78,26 @@ namespace Squidex.Domain.Apps.Entities.Rules.UsageTracking
{ {
var today = DateTime.Today; var today = DateTime.Today;
foreach (var kvp in state.Value.Targets) foreach (var (key, target) in state.Value.Targets)
{ {
var target = kvp.Value;
var from = GetFromDate(today, target.NumDays); var from = GetFromDate(today, target.NumDays);
if (!target.Triggered.HasValue || target.Triggered < from) if (!target.Triggered.HasValue || target.Triggered < from)
{ {
var usage = await usageTracker.GetMonthlyCallsAsync(target.AppId.Id.ToString(), today); var usage = await usageTracker.GetMonthlyCallsAsync(target.AppId.Id.ToString(), today);
var limit = kvp.Value.Limits; var limit = target.Limits;
if (usage > limit) if (usage > limit)
{ {
kvp.Value.Triggered = today; target.Triggered = today;
var @event = new AppUsageExceeded var @event = new AppUsageExceeded
{ {
AppId = target.AppId, AppId = target.AppId,
CallsCurrent = usage, CallsCurrent = usage,
CallsLimit = limit, CallsLimit = limit,
RuleId = kvp.Key RuleId = key
}; };
await state.WriteEventAsync(Envelope.Create<IEvent>(@event)); await state.WriteEventAsync(Envelope.Create<IEvent>(@event));

2
backend/src/Squidex.Domain.Apps.Entities/Rules/UsageTracking/UsageTriggerHandler.cs

@ -27,7 +27,7 @@ namespace Squidex.Domain.Apps.Entities.Rules.UsageTracking
Name = EventName Name = EventName
}; };
return Task.FromResult<EnrichedUsageExceededEvent?>(result); return Task.FromResult(result);
} }
protected override bool Trigger(EnrichedUsageExceededEvent @event, UsageTrigger trigger) protected override bool Trigger(EnrichedUsageExceededEvent @event, UsageTrigger trigger)

16
backend/src/Squidex.Domain.Apps.Entities/Schemas/Guards/GuardSchema.cs

@ -151,7 +151,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Guards
fieldIndex++; fieldIndex++;
fieldPrefix = $"Fields[{fieldIndex}]"; fieldPrefix = $"Fields[{fieldIndex}]";
ValidateRootField(field, command, fieldPrefix, e); ValidateRootField(field, fieldPrefix, e);
} }
foreach (var fieldName in command.Fields.Duplicates(x => x.Name)) foreach (var fieldName in command.Fields.Duplicates(x => x.Name))
@ -167,7 +167,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Guards
ValidateFieldNames(command, command.FieldsInReferences, nameof(command.FieldsInReferences), e, IsNotAllowed); ValidateFieldNames(command, command.FieldsInReferences, nameof(command.FieldsInReferences), e, IsNotAllowed);
} }
private static void ValidateRootField(UpsertSchemaField field, UpsertCommand command, string prefix, AddValidation e) private static void ValidateRootField(UpsertSchemaField field, string prefix, AddValidation e)
{ {
if (field == null) if (field == null)
{ {
@ -194,7 +194,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Guards
nestedIndex++; nestedIndex++;
nestedPrefix = $"{prefix}.Nested[{nestedIndex}]"; nestedPrefix = $"{prefix}.Nested[{nestedIndex}]";
ValidateNestedField(nestedField, field.Nested, nestedPrefix, e); ValidateNestedField(nestedField, nestedPrefix, e);
} }
} }
else if (field.Nested.Count > 0) else if (field.Nested.Count > 0)
@ -213,7 +213,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Guards
} }
} }
private static void ValidateNestedField(UpsertSchemaNestedField nestedField, IEnumerable<UpsertSchemaFieldBase> fields, string prefix, AddValidation e) private static void ValidateNestedField(UpsertSchemaNestedField nestedField, string prefix, AddValidation e)
{ {
if (nestedField == null) if (nestedField == null)
{ {
@ -282,11 +282,11 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Guards
} }
else if (field == null && !isAllowed(fieldName)) else if (field == null && !isAllowed(fieldName))
{ {
e($"Field is not part of the schema.", fieldPrefix); e("Field is not part of the schema.", fieldPrefix);
} }
else if (field?.IsUI() == true) else if (field?.IsUI() == true)
{ {
e($"Field cannot be an UI field.", fieldPrefix); e("Field cannot be an UI field.", fieldPrefix);
} }
} }
@ -320,11 +320,11 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Guards
} }
else if (field == null && !isAllowed(fieldName)) else if (field == null && !isAllowed(fieldName))
{ {
e($"Field is not part of the schema.", fieldPrefix); e("Field is not part of the schema.", fieldPrefix);
} }
else if (field?.Properties?.IsUIProperty() == true) else if (field?.Properties?.IsUIProperty() == true)
{ {
e($"Field cannot be an UI field.", fieldPrefix); e("Field cannot be an UI field.", fieldPrefix);
} }
} }

2
backend/src/Squidex.Domain.Apps.Entities/Schemas/Guards/GuardSchemaField.cs

@ -65,7 +65,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Guards
{ {
Guard.NotNull(command); Guard.NotNull(command);
var field = GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId, false); GuardHelper.GetFieldOrThrow(schema, command.FieldId, command.ParentFieldId, false);
Validate.It(() => "Cannot update field.", e => Validate.It(() => "Cannot update field.", e =>
{ {

2
backend/src/Squidex.Domain.Apps.Entities/Schemas/Indexes/SchemasIndex.cs

@ -135,7 +135,7 @@ namespace Squidex.Domain.Apps.Entities.Schemas.Indexes
} }
} }
private async Task<string?> CheckSchemaAsync(ISchemasByAppIndexGrain index, CreateSchema command) private static async Task<string?> CheckSchemaAsync(ISchemasByAppIndexGrain index, CreateSchema command)
{ {
var name = command.Name; var name = command.Name;

8
backend/src/Squidex.Domain.Apps.Entities/Tags/TagGrain.cs

@ -58,15 +58,15 @@ namespace Squidex.Domain.Apps.Entities.Tags
var tagName = tag.ToLowerInvariant(); var tagName = tag.ToLowerInvariant();
var tagId = string.Empty; var tagId = string.Empty;
var found = state.Value.Tags.FirstOrDefault(x => string.Equals(x.Value.Name, tagName, StringComparison.OrdinalIgnoreCase)); var (key, value) = state.Value.Tags.FirstOrDefault(x => string.Equals(x.Value.Name, tagName, StringComparison.OrdinalIgnoreCase));
if (found.Value != null) if (value != null)
{ {
tagId = found.Key; tagId = key;
if (ids == null || !ids.Contains(tagId)) if (ids == null || !ids.Contains(tagId))
{ {
found.Value.Count++; value.Count++;
} }
} }
else else

6
backend/src/Squidex.Infrastructure.MongoDb/Assets/MongoGridFsAssetStore.cs

@ -52,7 +52,7 @@ namespace Squidex.Infrastructure.Assets
{ {
var sourceName = GetFileName(sourceFileName, nameof(sourceFileName)); var sourceName = GetFileName(sourceFileName, nameof(sourceFileName));
using (var readStream = await bucket.OpenDownloadStreamAsync(sourceFileName, cancellationToken: ct)) using (var readStream = await bucket.OpenDownloadStreamAsync(sourceName, cancellationToken: ct))
{ {
await UploadAsync(targetFileName, readStream, false, ct); await UploadAsync(targetFileName, readStream, false, ct);
} }
@ -95,7 +95,7 @@ namespace Squidex.Infrastructure.Assets
await DeleteAsync(fileName); await DeleteAsync(fileName);
} }
await bucket.UploadFromStreamAsync(fileName, fileName, stream, cancellationToken: ct); await bucket.UploadFromStreamAsync(name, name, stream, cancellationToken: ct);
} }
catch (MongoWriteException ex) when (ex.WriteError.Category == ServerErrorCategory.DuplicateKey) catch (MongoWriteException ex) when (ex.WriteError.Category == ServerErrorCategory.DuplicateKey)
{ {
@ -123,7 +123,7 @@ namespace Squidex.Infrastructure.Assets
private static string GetFileName(string fileName, string parameterName) private static string GetFileName(string fileName, string parameterName)
{ {
Guard.NotNullOrEmpty(fileName); Guard.NotNullOrEmpty(fileName, parameterName);
return fileName; return fileName;
} }

2
backend/src/Squidex.Infrastructure.MongoDb/MongoDb/MongoExtensions.cs

@ -191,8 +191,6 @@ namespace Squidex.Infrastructure.MongoDb
{ {
await source.ForEachAsync(async i => await source.ForEachAsync(async i =>
{ {
var t = source;
if (!await actionBlock.SendAsync(i, combined.Token)) if (!await actionBlock.SendAsync(i, combined.Token))
{ {
selfToken.Cancel(); selfToken.Cancel();

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

@ -29,7 +29,7 @@ namespace Squidex.Infrastructure.MongoDb
protected static readonly ProjectionDefinitionBuilder<TEntity> Projection = Builders<TEntity>.Projection; protected static readonly ProjectionDefinitionBuilder<TEntity> Projection = Builders<TEntity>.Projection;
private readonly IMongoDatabase mongoDatabase; private readonly IMongoDatabase mongoDatabase;
private Lazy<IMongoCollection<TEntity>> mongoCollection; private readonly Lazy<IMongoCollection<TEntity>> mongoCollection;
protected IMongoCollection<TEntity> Collection protected IMongoCollection<TEntity> Collection
{ {

8
backend/src/Squidex.Infrastructure.MongoDb/MongoDb/Queries/SortBuilder.cs

@ -6,6 +6,7 @@
// ========================================================================== // ==========================================================================
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using MongoDB.Driver; using MongoDB.Driver;
using Squidex.Infrastructure.Queries; using Squidex.Infrastructure.Queries;
@ -17,12 +18,7 @@ namespace Squidex.Infrastructure.MongoDb.Queries
{ {
if (query.Sort.Count > 0) if (query.Sort.Count > 0)
{ {
var sorts = new List<SortDefinition<T>>(); var sorts = query.Sort.Select(OrderBy<T>).ToList();
foreach (var sort in query.Sort)
{
sorts.Add(OrderBy<T>(sort));
}
if (sorts.Count > 1) if (sorts.Count > 1)
{ {

4
backend/src/Squidex.Infrastructure.MongoDb/UsageTracking/MongoUsageRepository.cs

@ -85,9 +85,9 @@ namespace Squidex.Infrastructure.UsageTracking
.SetOnInsert(x => x.Date, usageUpdate.Date) .SetOnInsert(x => x.Date, usageUpdate.Date)
.SetOnInsert(x => x.Category, usageUpdate.Category); .SetOnInsert(x => x.Category, usageUpdate.Category);
foreach (var counter in usageUpdate.Counters) foreach (var (key, value) in usageUpdate.Counters)
{ {
update = update.Inc($"Counters.{counter.Key}", counter.Value); update = update.Inc($"Counters.{key}", value);
} }
var filter = Filter.Eq(x => x.Id, id); var filter = Filter.Eq(x => x.Id, id);

8
backend/src/Squidex.Infrastructure/CollectionExtensions.cs

@ -142,13 +142,13 @@ namespace Squidex.Infrastructure
{ {
var hashCode = 17; var hashCode = 17;
foreach (var kvp in dictionary.OrderBy(x => x.Key)) foreach (var (key, value) in dictionary.OrderBy(x => x.Key))
{ {
hashCode = (hashCode * 23) + keyComparer.GetHashCode(kvp.Key); hashCode = (hashCode * 23) + keyComparer.GetHashCode(key);
if (!Equals(kvp.Value, null)) if (!Equals(value, null))
{ {
hashCode = (hashCode * 23) + valueComparer.GetHashCode(kvp.Value); hashCode = (hashCode * 23) + valueComparer.GetHashCode(value);
} }
} }

6
backend/src/Squidex.Infrastructure/Commands/DomainObjectGrain.cs

@ -57,11 +57,11 @@ namespace Squidex.Infrastructure.Commands
snapshot = state; snapshot = state;
} }
protected sealed override async Task WriteAsync(Envelope<IEvent>[] events, long previousVersion) protected sealed override async Task WriteAsync(Envelope<IEvent>[] newEvents, long previousVersion)
{ {
if (events.Length > 0 && persistence != null) if (newEvents.Length > 0 && persistence != null)
{ {
await persistence.WriteEventsAsync(events); await persistence.WriteEventsAsync(newEvents);
await persistence.WriteSnapshotAsync(Snapshot); await persistence.WriteSnapshotAsync(Snapshot);
} }
} }

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

@ -212,7 +212,7 @@ namespace Squidex.Infrastructure.Commands
protected abstract Task ReadAsync(Type type, Guid id); protected abstract Task ReadAsync(Type type, Guid id);
protected abstract Task WriteAsync(Envelope<IEvent>[] events, long previousVersion); protected abstract Task WriteAsync(Envelope<IEvent>[] newEvents, long previousVersion);
public async Task<J<object?>> ExecuteAsync(J<IAggregateCommand> command) public async Task<J<object?>> ExecuteAsync(J<IAggregateCommand> command)
{ {

8
backend/src/Squidex.Infrastructure/Commands/LogSnapshotDomainObjectGrain.cs

@ -69,14 +69,14 @@ namespace Squidex.Infrastructure.Commands
return persistence.ReadAsync(); return persistence.ReadAsync();
} }
protected sealed override async Task WriteAsync(Envelope<IEvent>[] events, long previousVersion) protected sealed override async Task WriteAsync(Envelope<IEvent>[] newEvents, long previousVersion)
{ {
if (events.Length > 0 && persistence != null) if (newEvents.Length > 0 && persistence != null)
{ {
var persistedSnapshots = store.GetSnapshotStore<T>(); var persistedSnapshots = store.GetSnapshotStore<T>();
await persistence.WriteEventsAsync(events); await persistence.WriteEventsAsync(newEvents);
await persistedSnapshots.WriteAsync(Id, Snapshot, previousVersion, previousVersion + events.Length); await persistedSnapshots.WriteAsync(Id, Snapshot, previousVersion, previousVersion + newEvents.Length);
} }
} }

6
backend/src/Squidex.Infrastructure/Http/DumpFormatter.cs

@ -95,11 +95,11 @@ namespace Squidex.Infrastructure.Http
return; return;
} }
foreach (var header in headers) foreach (var (key, value) in headers)
{ {
writer.Append(header.Key); writer.Append(key);
writer.Append(": "); writer.Append(": ");
writer.Append(string.Join("; ", header.Value)); writer.Append(string.Join("; ", value));
writer.AppendLine(); writer.AppendLine();
} }
} }

6
backend/src/Squidex.Infrastructure/Json/Newtonsoft/JsonValueConverter.cs

@ -164,11 +164,11 @@ namespace Squidex.Infrastructure.Json.Newtonsoft
case JsonObject obj: case JsonObject obj:
writer.WriteStartObject(); writer.WriteStartObject();
foreach (var kvp in obj) foreach (var (key, jsonValue) in obj)
{ {
writer.WritePropertyName(kvp.Key); writer.WritePropertyName(key);
WriteJson(writer, kvp.Value); WriteJson(writer, jsonValue);
} }
writer.WriteEndObject(); writer.WriteEndObject();

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

@ -25,11 +25,11 @@ namespace Squidex.Infrastructure
public Task InitializeAsync(CancellationToken ct = default) public Task InitializeAsync(CancellationToken ct = default)
{ {
foreach (var kvp in options) foreach (var (key, value) in options)
{ {
if (!string.IsNullOrWhiteSpace(kvp.Key) && !string.IsNullOrWhiteSpace(kvp.Value)) if (!string.IsNullOrWhiteSpace(key) && !string.IsNullOrWhiteSpace(value))
{ {
Language.AddLanguage(kvp.Key, kvp.Value); Language.AddLanguage(key, value);
} }
} }

10
backend/src/Squidex.Infrastructure/Log/Adapter/SemanticLogLogger.cs

@ -75,15 +75,15 @@ namespace Squidex.Infrastructure.Log.Adapter
if (ctx.state is IReadOnlyList<KeyValuePair<string, object>> parameters) if (ctx.state is IReadOnlyList<KeyValuePair<string, object>> parameters)
{ {
foreach (var kvp in parameters) foreach (var (key, value) in parameters)
{ {
if (kvp.Value != null) if (value != null)
{ {
var key = kvp.Key.Trim('{', '}', ' '); var trimmedName = key.Trim('{', '}', ' ');
if (key.Length > 2 && !string.Equals(key, "originalFormat", StringComparison.OrdinalIgnoreCase)) if (trimmedName.Length > 2 && !string.Equals(trimmedName, "originalFormat", StringComparison.OrdinalIgnoreCase))
{ {
writer.WriteProperty(key.ToCamelCase(), kvp.Value.ToString()); writer.WriteProperty(trimmedName.ToCamelCase(), value.ToString());
} }
} }
} }

4
backend/src/Squidex.Infrastructure/Log/ProfilerSession.cs

@ -44,9 +44,9 @@ namespace Squidex.Infrastructure.Log
{ {
writer.WriteObject("profiler", p => writer.WriteObject("profiler", p =>
{ {
foreach (var kvp in traces) foreach (var (key, profilerItem) in traces)
{ {
p.WriteObject(kvp.Key, kvp.Value, (value, k) => k p.WriteObject(key, profilerItem, (value, k) => k
.WriteProperty("elapsedMsTotal", value.Total) .WriteProperty("elapsedMsTotal", value.Total)
.WriteProperty("elapsedMsAvg", value.Total / value.Count) .WriteProperty("elapsedMsAvg", value.Total / value.Count)
.WriteProperty("count", value.Count)); .WriteProperty("count", value.Count));

2
backend/src/Squidex.Infrastructure/Migrations/Migrator.cs

@ -45,7 +45,7 @@ namespace Squidex.Infrastructure.Migrations
.WriteProperty("action", "Migrate") .WriteProperty("action", "Migrate")
.WriteProperty("mesage", $"Waiting {LockWaitMs}ms to acquire lock.")); .WriteProperty("mesage", $"Waiting {LockWaitMs}ms to acquire lock."));
await Task.Delay(LockWaitMs); await Task.Delay(LockWaitMs, ct);
} }
version = await migrationStatus.GetVersionAsync(); version = await migrationStatus.GetVersionAsync();

8
backend/src/Squidex.Infrastructure/Plugins/PluginManager.cs

@ -119,12 +119,12 @@ namespace Squidex.Infrastructure.Plugins
.WriteProperty("status", status) .WriteProperty("status", status)
.WriteArray("errors", e => .WriteArray("errors", e =>
{ {
foreach (var error in exceptions) foreach (var (plugin, action, exception) in exceptions)
{ {
e.WriteObject(x => x e.WriteObject(x => x
.WriteProperty("plugin", error.Plugin) .WriteProperty("plugin", plugin)
.WriteProperty("action", error.Action) .WriteProperty("action", action)
.WriteException(error.Exception)); .WriteException(exception));
} }
}) })
.WriteArray("plugins", a => .WriteArray("plugins", a =>

2
backend/src/Squidex.Infrastructure/Security/Permission.cs

@ -24,7 +24,7 @@ namespace Squidex.Infrastructure.Security
private Part[] Path private Part[] Path
{ {
get { return path ?? (path = Part.ParsePath(id)); } get { return path ??= Part.ParsePath(id); }
} }
public Permission(string id) public Permission(string id)

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

@ -69,16 +69,16 @@ namespace Squidex.Infrastructure.UsageTracking
var updates = new UsageUpdate[localUsages.Count]; var updates = new UsageUpdate[localUsages.Count];
var updateIndex = 0; var updateIndex = 0;
foreach (var kvp in localUsages) foreach (var (key, value) in localUsages)
{ {
var counters = new Counters var counters = new Counters
{ {
[CounterTotalCalls] = kvp.Value.Count, [CounterTotalCalls] = value.Count,
[CounterTotalElapsedMs] = kvp.Value.ElapsedMs [CounterTotalElapsedMs] = value.ElapsedMs
}; };
updates[updateIndex].Key = kvp.Key.Key; updates[updateIndex].Key = key.Key;
updates[updateIndex].Category = kvp.Key.Category; updates[updateIndex].Category = key.Category;
updates[updateIndex].Counters = counters; updates[updateIndex].Counters = counters;
updates[updateIndex].Date = today; updates[updateIndex].Date = today;

7
backend/src/Squidex.Infrastructure/Validation/AbsoluteUrlAttribute.cs

@ -19,12 +19,7 @@ namespace Squidex.Infrastructure.Validation
public override bool IsValid(object value) public override bool IsValid(object value)
{ {
if (value is Uri uri && !uri.IsAbsoluteUri) return !(value is Uri uri) || uri.IsAbsoluteUri;
{
return false;
}
return true;
} }
} }
} }

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

@ -45,9 +45,9 @@ namespace Squidex.Web
{ {
var id = permissionId; var id = permissionId;
foreach (var routeParam in context.RouteData.Values) foreach (var (key, value) in context.RouteData.Values)
{ {
id = id.Replace($"{{{routeParam.Key}}}", routeParam.Value?.ToString()); id = id.Replace($"{{{key}}}", value?.ToString());
} }
if (permissions.Allows(new Permission(id))) if (permissions.Allows(new Permission(id)))

6
backend/src/Squidex.Web/ContextExtensions.cs

@ -21,11 +21,11 @@ namespace Squidex.Web
{ {
context = new Context(httpContext.User); context = new Context(httpContext.User);
foreach (var header in httpContext.Request.Headers) foreach (var (key, value) in httpContext.Request.Headers)
{ {
if (header.Key.StartsWith("X-", StringComparison.OrdinalIgnoreCase)) if (key.StartsWith("X-", StringComparison.OrdinalIgnoreCase))
{ {
context.Headers.Add(header.Key, header.Value.ToString()); context.Headers.Add(key, value.ToString());
} }
} }

6
backend/src/Squidex.Web/ExposedValues.cs

@ -47,16 +47,16 @@ namespace Squidex.Web
{ {
var sb = new StringBuilder(); var sb = new StringBuilder();
foreach (var kvp in this) foreach (var (key, value) in this)
{ {
if (sb.Length > 0) if (sb.Length > 0)
{ {
sb.Append(", "); sb.Append(", ");
} }
sb.Append(kvp.Key); sb.Append(key);
sb.Append(": "); sb.Append(": ");
sb.Append(kvp.Value); sb.Append(value);
} }
return sb.ToString(); return sb.ToString();

4
backend/src/Squidex.Web/Pipeline/ActionContextLogAppender.cs

@ -57,9 +57,9 @@ namespace Squidex.Web.Pipeline
{ {
w.WriteObject("routeValues", actionContext.ActionDescriptor.RouteValues, (routeValues, r) => w.WriteObject("routeValues", actionContext.ActionDescriptor.RouteValues, (routeValues, r) =>
{ {
foreach (var kvp in routeValues) foreach (var (key, value) in routeValues)
{ {
r.WriteProperty(kvp.Key, kvp.Value); r.WriteProperty(key, value);
} }
}); });
} }

1
backend/src/Squidex/Areas/Api/Controllers/Assets/Models/AssetFolderDto.cs

@ -7,7 +7,6 @@
using System; using System;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Newtonsoft.Json;
using Squidex.Domain.Apps.Entities.Assets; using Squidex.Domain.Apps.Entities.Assets;
using Squidex.Infrastructure.Reflection; using Squidex.Infrastructure.Reflection;
using Squidex.Shared; using Squidex.Shared;

4
backend/src/Squidex/Areas/Api/Controllers/Contents/Models/ContentsDto.cs

@ -62,7 +62,7 @@ namespace Squidex.Areas.Api.Controllers.Contents.Models
Statuses = allStatuses.Select(StatusInfoDto.FromStatusInfo).ToArray(); Statuses = allStatuses.Select(StatusInfoDto.FromStatusInfo).ToArray();
} }
private ContentsDto CreateLinks(ApiController controller, string app, string schema) private void CreateLinks(ApiController controller, string app, string schema)
{ {
var values = new { app, name = schema }; var values = new { app, name = schema };
@ -74,8 +74,6 @@ namespace Squidex.Areas.Api.Controllers.Contents.Models
AddPostLink("create/publish", controller.Url<ContentsController>(x => nameof(x.PostContent), values) + "?publish=true"); AddPostLink("create/publish", controller.Url<ContentsController>(x => nameof(x.PostContent), values) + "?publish=true");
} }
return this;
} }
} }
} }

2
backend/src/Squidex/Areas/Frontend/Middlewares/IndexExtensions.cs

@ -53,7 +53,7 @@ namespace Squidex.Areas.Frontend.Middlewares
} }
var jsonSerializer = httpContext.RequestServices.GetRequiredService<IJsonSerializer>(); var jsonSerializer = httpContext.RequestServices.GetRequiredService<IJsonSerializer>();
var jsonOptions = jsonSerializer.Serialize(uiOptions, false); var jsonOptions = jsonSerializer.Serialize(uiOptions);
result = result.Replace("<body>", $"<body><script>var options = {jsonOptions};</script>"); result = result.Replace("<body>", $"<body><script>var options = {jsonOptions};</script>");
} }

2
backend/src/Squidex/Areas/Frontend/Middlewares/IndexMiddleware.cs

@ -23,8 +23,6 @@ namespace Squidex.Areas.Frontend.Middlewares
public async Task Invoke(HttpContext context) public async Task Invoke(HttpContext context)
{ {
var basePath = context.Request.PathBase;
if (context.IsHtmlPath() && context.Response.StatusCode != 304) if (context.IsHtmlPath() && context.Response.StatusCode != 304)
{ {
var responseBuffer = new MemoryStream(); var responseBuffer = new MemoryStream();

2
backend/src/Squidex/Areas/IdentityServer/Views/Profile/Profile.cshtml

@ -238,7 +238,7 @@
<label for="generate">&nbsp;</label> <label for="generate">&nbsp;</label>
<form class="profile-form" asp-controller="Profile" asp-action="GenerateClientSecret" method="post"> <form class="profile-form" asp-controller="Profile" asp-action="GenerateClientSecret" method="post">
<button type="submit" class="btn btn-success btn-block">Generate</button> <button type="submit" class="btn btn-success btn-block" id="generate">Generate</button>
</form> </form>
</div> </div>
</div> </div>

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

@ -49,7 +49,7 @@ namespace Squidex.Config.Authentication
if (pictureUrl != null && pictureUrl.EndsWith("?sz=50", System.StringComparison.Ordinal)) if (pictureUrl != null && pictureUrl.EndsWith("?sz=50", System.StringComparison.Ordinal))
{ {
pictureUrl = pictureUrl[0..^6]; pictureUrl = pictureUrl[..^6];
} }
} }

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

@ -13,7 +13,7 @@ namespace Squidex.Config.Domain
{ {
public static void ConfigureForSquidex(this IConfigurationBuilder builder) public static void ConfigureForSquidex(this IConfigurationBuilder builder)
{ {
builder.AddJsonFile($"appsettings.Custom.json", true); builder.AddJsonFile("appsettings.Custom.json", true);
} }
} }
} }

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

@ -24,7 +24,7 @@ namespace Squidex.Config.Domain
services.Configure<ContentOptions>( services.Configure<ContentOptions>(
config.GetSection("contents")); config.GetSection("contents"));
services.AddSingletonAs(c => new Lazy<IContentQueryService>(() => c.GetRequiredService<IContentQueryService>())) services.AddSingletonAs(c => new Lazy<IContentQueryService>(c.GetRequiredService<IContentQueryService>))
.AsSelf(); .AsSelf();
services.AddSingletonAs<ContentQueryParser>() services.AddSingletonAs<ContentQueryParser>()

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

@ -32,7 +32,7 @@ namespace Squidex.Config.Domain
exposeSourceUrl)) exposeSourceUrl))
.As<IGraphQLUrlGenerator>().As<IRuleUrlGenerator>().As<IAssetUrlGenerator>().As<IEmailUrlGenerator>(); .As<IGraphQLUrlGenerator>().As<IRuleUrlGenerator>().As<IAssetUrlGenerator>().As<IEmailUrlGenerator>();
services.AddSingletonAs(x => new FuncDependencyResolver(t => x.GetRequiredService(t))) services.AddSingletonAs(x => new FuncDependencyResolver(x.GetRequiredService))
.As<IDependencyResolver>(); .As<IDependencyResolver>();
services.AddSingletonAs<DataLoaderContextAccessor>() services.AddSingletonAs<DataLoaderContextAccessor>()

1
backend/src/Squidex/Config/Orleans/OrleansServices.cs

@ -9,7 +9,6 @@ using System.Net;
using System.Net.Sockets; using System.Net.Sockets;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Orleans; using Orleans;
using Orleans.Configuration; using Orleans.Configuration;
using Orleans.Hosting; using Orleans.Hosting;

10
backend/tests/Squidex.Domain.Apps.Core.Tests/Model/Apps/RolesTests.cs

@ -138,13 +138,13 @@ namespace Squidex.Domain.Apps.Core.Model.Apps
[Theory] [Theory]
public void Should_get_default_roles(string name) public void Should_get_default_roles(string name)
{ {
var found = roles_0.TryGet("app", name, out var role); var found = roles_0.TryGet("app", name, out var result);
Assert.True(found); Assert.True(found);
Assert.True(role!.IsDefault); Assert.True(result!.IsDefault);
Assert.True(roles_0.Contains(name)); Assert.True(roles_0.Contains(name));
foreach (var permission in role.Permissions) foreach (var permission in result.Permissions)
{ {
Assert.StartsWith("squidex.apps.app.", permission.Id); Assert.StartsWith("squidex.apps.app.", permission.Id);
} }
@ -153,10 +153,10 @@ namespace Squidex.Domain.Apps.Core.Model.Apps
[Fact] [Fact]
public void Should_return_null_if_role_not_found() public void Should_return_null_if_role_not_found()
{ {
var found = roles_0.TryGet("app", "custom", out var role); var found = roles_0.TryGet("app", "custom", out var result);
Assert.False(found); Assert.False(found);
Assert.Null(role); Assert.Null(result);
} }
} }
} }

9
backend/tests/Squidex.Domain.Apps.Core.Tests/Operations/EventSynchronization/SchemaSynchronizerTests.cs

@ -569,9 +569,6 @@ namespace Squidex.Domain.Apps.Core.Operations.EventSynchronization
[Fact] [Fact]
public void Should_create_events_if_fields_reordered() public void Should_create_events_if_fields_reordered()
{ {
var id1 = NamedId.Of(1, "f1");
var id2 = NamedId.Of(2, "f1");
var sourceSchema = var sourceSchema =
new Schema("source") new Schema("source")
.AddString(10, "f1", Partitioning.Invariant) .AddString(10, "f1", Partitioning.Invariant)
@ -592,9 +589,6 @@ namespace Squidex.Domain.Apps.Core.Operations.EventSynchronization
[Fact] [Fact]
public void Should_create_events_if_fields_reordered_after_sync() public void Should_create_events_if_fields_reordered_after_sync()
{ {
var id1 = NamedId.Of(1, "f1");
var id2 = NamedId.Of(2, "f1");
var sourceSchema = var sourceSchema =
new Schema("source") new Schema("source")
.AddString(10, "f1", Partitioning.Invariant) .AddString(10, "f1", Partitioning.Invariant)
@ -617,9 +611,6 @@ namespace Squidex.Domain.Apps.Core.Operations.EventSynchronization
[Fact] [Fact]
public void Should_create_events_if_fields_reordered_after_sync2() public void Should_create_events_if_fields_reordered_after_sync2()
{ {
var id1 = NamedId.Of(1, "f1");
var id2 = NamedId.Of(2, "f1");
var sourceSchema = var sourceSchema =
new Schema("source") new Schema("source")
.AddString(10, "f1", Partitioning.Invariant) .AddString(10, "f1", Partitioning.Invariant)

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/BackupAppsTests.cs

@ -126,8 +126,6 @@ namespace Squidex.Domain.Apps.Entities.Apps
[Fact] [Fact]
public async Task Should_not_cleanup_reservation_when_no_reservation_token_hold() public async Task Should_not_cleanup_reservation_when_no_reservation_token_hold()
{ {
var context = CreateRestoreContext();
await sut.CleanupRestoreErrorAsync(appId); await sut.CleanupRestoreErrorAsync(appId);
A.CallTo(() => index.RemoveReservationAsync("Reservation")) A.CallTo(() => index.RemoveReservationAsync("Reservation"))

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Apps/Indexes/AppsIndexTests.cs

@ -267,7 +267,7 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes
[Theory, InlineData(true), InlineData(false)] [Theory, InlineData(true), InlineData(false)]
public async Task Should_remove_app_from_indexes_on_archive(bool isArchived) public async Task Should_remove_app_from_indexes_on_archive(bool isArchived)
{ {
var app = SetupApp(0, isArchived); SetupApp(0, isArchived);
var context = var context =
new CommandContext(new ArchiveApp { AppId = appId.Id }, commandBus) new CommandContext(new ArchiveApp { AppId = appId.Id }, commandBus)

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Guards/GuardAssetFolderTests.cs

@ -155,7 +155,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.Guards
GuardAssetFolder.CanDelete(command); GuardAssetFolder.CanDelete(command);
} }
private IAssetFolderEntity CreateFolder(Guid id = default) private static IAssetFolderEntity CreateFolder(Guid id = default)
{ {
var assetFolder = A.Fake<IAssetFolderEntity>(); var assetFolder = A.Fake<IAssetFolderEntity>();

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Guards/GuardAssetTests.cs

@ -124,7 +124,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.Guards
GuardAsset.CanDelete(command); GuardAsset.CanDelete(command);
} }
private IAssetFolderEntity CreateFolder(Guid id = default) private static IAssetFolderEntity CreateFolder(Guid id = default)
{ {
var assetFolder = A.Fake<IAssetFolderEntity>(); var assetFolder = A.Fake<IAssetFolderEntity>();

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Assets/Queries/AssetQueryServiceTests.cs

@ -229,7 +229,7 @@ namespace Squidex.Domain.Apps.Entities.Assets.Queries
Assert.Empty(result); Assert.Empty(result);
} }
private IAssetFolderEntity CreateFolder(Guid id, Guid parentId = default) private static IAssetFolderEntity CreateFolder(Guid id, Guid parentId = default)
{ {
var assetFolder = A.Fake<IAssetFolderEntity>(); var assetFolder = A.Fake<IAssetFolderEntity>();

6
backend/tests/Squidex.Domain.Apps.Entities.Tests/Backup/BackupReaderWriterTests.cs

@ -96,12 +96,12 @@ namespace Squidex.Domain.Apps.Entities.Backup
using (var writer = new BackupWriter(serializer, stream, true, version)) using (var writer = new BackupWriter(serializer, stream, true, version))
{ {
foreach (var @event in sourceEvents) foreach (var (_, envelope) in sourceEvents)
{ {
var eventData = formatter.ToEventData(@event.Event, Guid.NewGuid(), true); var eventData = formatter.ToEventData(envelope, Guid.NewGuid(), true);
var eventStored = new StoredEvent("S", "1", 2, eventData); var eventStored = new StoredEvent("S", "1", 2, eventData);
var index = int.Parse(@event.Event.Headers["Index"].ToString()); var index = int.Parse(envelope.Headers["Index"].ToString());
if (index % 17 == 0) if (index % 17 == 0)
{ {

2
backend/tests/Squidex.Domain.Apps.Entities.Tests/Backup/UserMappingTests.cs

@ -125,7 +125,7 @@ namespace Squidex.Domain.Apps.Entities.Backup
Assert.Same(client, mapped); Assert.Same(client, mapped);
} }
private IUser CreateUser(string id, string email) private static IUser CreateUser(string id, string email)
{ {
var user = A.Fake<IUser>(); var user = A.Fake<IUser>();

8
backend/tests/Squidex.Domain.Apps.Entities.Tests/Contents/Guard/GuardContentTests.cs

@ -97,8 +97,6 @@ namespace Squidex.Domain.Apps.Entities.Contents.Guard
[Fact] [Fact]
public async Task CanUpdate_should_throw_exception_if_data_is_null() public async Task CanUpdate_should_throw_exception_if_data_is_null()
{ {
var schema = CreateSchema(false);
SetupCanUpdate(true); SetupCanUpdate(true);
var content = CreateContent(Status.Draft, false); var content = CreateContent(Status.Draft, false);
@ -111,8 +109,6 @@ namespace Squidex.Domain.Apps.Entities.Contents.Guard
[Fact] [Fact]
public async Task CanUpdate_should_throw_exception_if_workflow_blocks_it() public async Task CanUpdate_should_throw_exception_if_workflow_blocks_it()
{ {
var schema = CreateSchema(false);
SetupCanUpdate(false); SetupCanUpdate(false);
var content = CreateContent(Status.Draft, false); var content = CreateContent(Status.Draft, false);
@ -135,8 +131,6 @@ namespace Squidex.Domain.Apps.Entities.Contents.Guard
[Fact] [Fact]
public async Task CanPatch_should_throw_exception_if_data_is_null() public async Task CanPatch_should_throw_exception_if_data_is_null()
{ {
var schema = CreateSchema(false);
SetupCanUpdate(true); SetupCanUpdate(true);
var content = CreateContent(Status.Draft, false); var content = CreateContent(Status.Draft, false);
@ -149,8 +143,6 @@ namespace Squidex.Domain.Apps.Entities.Contents.Guard
[Fact] [Fact]
public async Task CanPatch_should_throw_exception_if_workflow_blocks_it() public async Task CanPatch_should_throw_exception_if_workflow_blocks_it()
{ {
var schema = CreateSchema(false);
SetupCanUpdate(false); SetupCanUpdate(false);
var content = CreateContent(Status.Draft, false); var content = CreateContent(Status.Draft, false);

7
backend/tests/Squidex.Domain.Apps.Entities.Tests/TestHelpers/AExtensions.cs

@ -19,12 +19,7 @@ namespace Squidex.Domain.Apps.Entities.TestHelpers
public static T[] Is<T>(this INegatableArgumentConstraintManager<T[]> that, params T[]? values) public static T[] Is<T>(this INegatableArgumentConstraintManager<T[]> that, params T[]? values)
{ {
if (values == null) return values == null ? that.IsNull() : that.IsSameSequenceAs(values);
{
return that.IsNull();
}
return that.IsSameSequenceAs(values);
} }
} }
} }

4
backend/tests/Squidex.Infrastructure.Tests/Log/SemanticLogTests.cs

@ -49,8 +49,8 @@ namespace Squidex.Infrastructure.Log
[Fact] [Fact]
public void Should_log_multiple_lines() public void Should_log_multiple_lines()
{ {
Log.Log<None>(SemanticLogLevel.Error, None.Value, (_, w) => w.WriteProperty("logMessage", "Msg1")); Log.Log(SemanticLogLevel.Error, None.Value, (_, w) => w.WriteProperty("logMessage", "Msg1"));
Log.Log<None>(SemanticLogLevel.Error, None.Value, (_, w) => w.WriteProperty("logMessage", "Msg2")); Log.Log(SemanticLogLevel.Error, None.Value, (_, w) => w.WriteProperty("logMessage", "Msg2"));
var expected1 = var expected1 =
LogTest(w => w LogTest(w => w

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

@ -61,7 +61,7 @@ namespace Squidex.Web.Pipeline
[Fact] [Fact]
public async Task Should_not_redirect_if_not_required() public async Task Should_not_redirect_if_not_required()
{ {
var httpContext = CreateHttpContext("http"); var httpContext = CreateHttpContext();
options.EnforceHTTPS = false; options.EnforceHTTPS = false;

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

@ -114,9 +114,9 @@ namespace Migrate_01.Migrations
await indexApps.RebuildAsync(appsByName); await indexApps.RebuildAsync(appsByName);
foreach (var kvp in appsByUser) foreach (var (contributorId, apps) in appsByUser)
{ {
await indexApps.RebuildByContributorsAsync(kvp.Key, kvp.Value); await indexApps.RebuildByContributorsAsync(contributorId, apps);
} }
} }
@ -146,9 +146,9 @@ namespace Migrate_01.Migrations
return TaskHelper.Done; return TaskHelper.Done;
}, "^rule\\-"); }, "^rule\\-");
foreach (var kvp in rulesByApp) foreach (var (appId, rules) in rulesByApp)
{ {
await indexRules.RebuildAsync(kvp.Key, kvp.Value); await indexRules.RebuildAsync(appId, rules);
} }
} }
@ -178,9 +178,9 @@ namespace Migrate_01.Migrations
return TaskHelper.Done; return TaskHelper.Done;
}, "^schema\\-"); }, "^schema\\-");
foreach (var kvp in schemasByApp) foreach (var (appId, schemas) in schemasByApp)
{ {
await indexSchemas.RebuildAsync(kvp.Key, kvp.Value); await indexSchemas.RebuildAsync(appId, schemas);
} }
} }
} }

Loading…
Cancel
Save