Skip to content

Commit 40f671d

Browse files
authored
Merge branch 'v15/dev' into v15/bugfix/18000
2 parents 412fe69 + 2cdcacb commit 40f671d

File tree

204 files changed

+5915
-5359
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

204 files changed

+5915
-5359
lines changed

src/Umbraco.Cms.Api.Delivery/Querying/Filters/ContainsFilterBase.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ public FilterOption BuildFilterOption(string filter)
3737
{
3838
GroupCollection groups = QueryParserRegex.Match(filter).Groups;
3939

40-
if (groups.Count != 3 || groups.ContainsKey("operator") is false || groups.ContainsKey("value") is false)
40+
if (groups.Count != 3 || groups.TryGetValue("operator", out Group? operatorGroup) is false || groups.TryGetValue("value", out Group? valueGroup) is false)
4141
{
4242
return DefaultFilterOption();
4343
}
4444

45-
FilterOperation? filterOperation = ParseFilterOperation(groups["operator"].Value);
45+
FilterOperation? filterOperation = ParseFilterOperation(operatorGroup.Value);
4646
if (filterOperation.HasValue is false)
4747
{
4848
return DefaultFilterOption();
@@ -51,7 +51,7 @@ public FilterOption BuildFilterOption(string filter)
5151
return new FilterOption
5252
{
5353
FieldName = FieldName,
54-
Values = new[] { groups["value"].Value },
54+
Values = [valueGroup.Value],
5555
Operator = filterOperation.Value
5656
};
5757

src/Umbraco.Cms.Api.Delivery/Services/ApiContentQueryProvider.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,14 @@ public PagedModel<Guid> ExecuteQuery(
7979
return new PagedModel<Guid>();
8080
}
8181

82-
Guid[] items = results
83-
.Where(r => r.Values.ContainsKey(ItemIdFieldName))
84-
.Select(r => Guid.Parse(r.Values[ItemIdFieldName]))
85-
.ToArray();
82+
List<Guid> items = [];
83+
foreach (ISearchResult result in results)
84+
{
85+
if (result.Values.TryGetValue(ItemIdFieldName, out string? value))
86+
{
87+
items.Add(Guid.Parse(value));
88+
}
89+
}
8690

8791
return new PagedModel<Guid>(results.TotalItemCount, items);
8892
}

src/Umbraco.Cms.Api.Management/Controllers/HealthCheck/ExecuteActionHealthCheckController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public async Task<ActionResult<HealthCheckResultResponseModel>> ExecuteAction(
6161
return BadRequest(invalidModelProblem);
6262
}
6363

64-
HealthCheckStatus result = healthCheck.ExecuteAction(_umbracoMapper.Map<HealthCheckAction>(action)!);
64+
HealthCheckStatus result = await healthCheck.ExecuteActionAsync(_umbracoMapper.Map<HealthCheckAction>(action)!);
6565

6666
return await Task.FromResult(Ok(_umbracoMapper.Map<HealthCheckResultResponseModel>(result)));
6767
}

src/Umbraco.Cms.Api.Management/Controllers/HealthCheck/Group/CheckHealthCheckGroupController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ public async Task<IActionResult> ByNameWithResult(
3939
return HealthCheckGroupNotFound();
4040
}
4141

42-
return await Task.FromResult(Ok(_healthCheckGroupPresentationFactory.CreateHealthCheckGroupWithResultViewModel(group)));
42+
return Ok(await _healthCheckGroupPresentationFactory.CreateHealthCheckGroupWithResultViewModelAsync(group));
4343
}
4444
}

src/Umbraco.Cms.Api.Management/Controllers/Template/Query/ExecuteTemplateQueryController.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ private IEnumerable<IPublishedContent> BuildQuery(TemplateQueryExecuteModel mode
9898
if (model.RootDocument?.Id is not null)
9999
{
100100
rootContent = _publishedContentQuery.Content(model.RootDocument.Id);
101-
queryExpression.Append($"Umbraco.Content(Guid.Parse(\"{model.RootDocument.Id}\"))");
101+
queryExpression.Append("Umbraco.Content(Guid.Parse(\"").Append(model.RootDocument.Id).Append("\"))");
102102
}
103103
else
104104
{
@@ -115,7 +115,7 @@ private IEnumerable<IPublishedContent> GetRootContentQuery(TemplateQueryExecuteM
115115

116116
if (model.DocumentTypeAlias.IsNullOrWhiteSpace() == false)
117117
{
118-
queryExpression.Append($".ChildrenOfType(\"{model.DocumentTypeAlias}\")");
118+
queryExpression.Append(".ChildrenOfType(\"").Append(model.DocumentTypeAlias).Append("\")");
119119
return rootContent == null
120120
? Enumerable.Empty<IPublishedContent>()
121121
: rootContent.ChildrenOfType(_variationContextAccessor, _contentCache, _documentNavigationQueryService, model.DocumentTypeAlias);
@@ -176,7 +176,7 @@ string PropertyModelType(TemplateQueryPropertyType templateQueryPropertyType)
176176
//for review - this uses a tonized query rather then the normal linq query.
177177
contentQuery = contentQuery.Where(operation.Compile());
178178
queryExpression.Append(_indent);
179-
queryExpression.Append($".Where({operation})");
179+
queryExpression.Append(".Where(").Append(operation).Append(')');
180180
}
181181

182182
return contentQuery;
@@ -220,7 +220,7 @@ private IEnumerable<IPublishedContent> ApplySorting(TemplateQueryExecuteSortMode
220220
return contentQuery;
221221
}
222222

223-
private IEnumerable<IPublishedContent> ApplyPaging(int take, IEnumerable<IPublishedContent> contentQuery, StringBuilder queryExpression)
223+
private static IEnumerable<IPublishedContent> ApplyPaging(int take, IEnumerable<IPublishedContent> contentQuery, StringBuilder queryExpression)
224224
{
225225
if (take <= 0)
226226
{
@@ -229,7 +229,7 @@ private IEnumerable<IPublishedContent> ApplyPaging(int take, IEnumerable<IPublis
229229

230230
contentQuery = contentQuery.Take(take);
231231
queryExpression.Append(_indent);
232-
queryExpression.Append($".Take({take})");
232+
queryExpression.Append(".Take(").Append(take).Append(')');
233233

234234
return contentQuery;
235235
}

src/Umbraco.Cms.Api.Management/Factories/HealthCheckGroupPresentationFactory.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Umbraco.Cms.Api.Management.Factories;
99

10+
// TODO (V16): Make internal sealed.
1011
public class HealthCheckGroupPresentationFactory : IHealthCheckGroupPresentationFactory
1112
{
1213
private readonly HealthChecksSettings _healthChecksSettings;
@@ -40,13 +41,21 @@ public HealthCheckGroupPresentationFactory(
4041
return groups;
4142
}
4243

44+
[Obsolete("Use CreateHealthCheckGroupWithResultViewModelAsync instead. Will be removed in v17.")]
4345
public HealthCheckGroupWithResultResponseModel CreateHealthCheckGroupWithResultViewModel(IGrouping<string?, HealthCheck> healthCheckGroup)
46+
=> CreateHealthCheckGroupWithResultViewModelAsync(healthCheckGroup).GetAwaiter().GetResult();
47+
48+
[Obsolete("Use CreateHealthCheckGroupWithResultViewModelAsync instead. Will be removed in v17.")]
49+
public HealthCheckWithResultPresentationModel CreateHealthCheckWithResultViewModel(HealthCheck healthCheck) =>
50+
CreateHealthCheckWithResultViewModelAsync(healthCheck).GetAwaiter().GetResult();
51+
52+
public async Task<HealthCheckGroupWithResultResponseModel> CreateHealthCheckGroupWithResultViewModelAsync(IGrouping<string?, HealthCheck> healthCheckGroup)
4453
{
4554
var healthChecks = new List<HealthCheckWithResultPresentationModel>();
4655

4756
foreach (HealthCheck healthCheck in healthCheckGroup)
4857
{
49-
healthChecks.Add(CreateHealthCheckWithResultViewModel(healthCheck));
58+
healthChecks.Add(await CreateHealthCheckWithResultViewModelAsync(healthCheck));
5059
}
5160

5261
var healthCheckGroupViewModel = new HealthCheckGroupWithResultResponseModel
@@ -57,11 +66,11 @@ public HealthCheckGroupWithResultResponseModel CreateHealthCheckGroupWithResultV
5766
return healthCheckGroupViewModel;
5867
}
5968

60-
public HealthCheckWithResultPresentationModel CreateHealthCheckWithResultViewModel(HealthCheck healthCheck)
69+
public async Task<HealthCheckWithResultPresentationModel> CreateHealthCheckWithResultViewModelAsync(HealthCheck healthCheck)
6170
{
6271
_logger.LogDebug($"Running health check: {healthCheck.Name}");
6372

64-
IEnumerable<HealthCheckStatus> results = healthCheck.GetStatus().Result;
73+
IEnumerable<HealthCheckStatus> results = await healthCheck.GetStatusAsync();
6574

6675
var healthCheckViewModel = new HealthCheckWithResultPresentationModel
6776
{

src/Umbraco.Cms.Api.Management/Factories/IHealthCheckGroupPresentationFactory.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,19 @@ public interface IHealthCheckGroupPresentationFactory
77
{
88
IEnumerable<IGrouping<string?, HealthCheck>> CreateGroupingFromHealthCheckCollection();
99

10+
[Obsolete("Use CreateHealthCheckGroupWithResultViewModelAsync instead. Will be removed in v17.")]
1011
HealthCheckGroupWithResultResponseModel CreateHealthCheckGroupWithResultViewModel(IGrouping<string?, HealthCheck> healthCheckGroup);
1112

13+
[Obsolete("Use CreateHealthCheckGroupWithResultViewModelAsync instead. Will be removed in v17.")]
1214
HealthCheckWithResultPresentationModel CreateHealthCheckWithResultViewModel(HealthCheck healthCheck);
15+
16+
Task<HealthCheckGroupWithResultResponseModel> CreateHealthCheckGroupWithResultViewModelAsync(IGrouping<string?, HealthCheck> healthCheckGroup)
17+
#pragma warning disable CS0618 // Type or member is obsolete
18+
=> Task.FromResult(CreateHealthCheckGroupWithResultViewModel(healthCheckGroup));
19+
#pragma warning restore CS0618 // Type or member is obsolete
20+
21+
Task<HealthCheckWithResultPresentationModel> CreateHealthCheckWithResultViewModelAsync(HealthCheck healthCheck)
22+
#pragma warning disable CS0618 // Type or member is obsolete
23+
=> Task.FromResult(CreateHealthCheckWithResultViewModel(healthCheck));
24+
#pragma warning restore CS0618 // Type or member is obsolete
1325
}

src/Umbraco.Cms.Api.Management/Mapping/ContentType/ContentTypeMapDefinition.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ protected IEnumerable<TPropertyTypeModel> MapPropertyTypes(TContentType source)
2525
{
2626
Id = propertyType.Key,
2727
SortOrder = propertyType.SortOrder,
28-
Container = groupKeysByPropertyKeys.ContainsKey(propertyType.Key)
29-
? new ReferenceByIdModel(groupKeysByPropertyKeys[propertyType.Key])
28+
Container = groupKeysByPropertyKeys.TryGetValue(propertyType.Key, out Guid groupKey)
29+
? new ReferenceByIdModel(groupKey)
3030
: null,
3131
Name = propertyType.Name,
3232
Alias = propertyType.Alias,

src/Umbraco.Cms.Api.Management/Services/ConflictingRouteService.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System.Reflection;
2+
using System.Runtime.InteropServices;
23
using Umbraco.Cms.Api.Management.Controllers;
34
using Umbraco.Cms.Core.Composing;
45
using Umbraco.Cms.Core.Services;
@@ -19,7 +20,7 @@ public class ConflictingRouteService : IConflictingRouteService
1920
public bool HasConflictingRoutes(out string controllerName)
2021
{
2122
var controllers = _typeLoader.GetTypes<ManagementApiControllerBase>().ToList();
22-
foreach (Type controller in controllers)
23+
foreach (Type controller in CollectionsMarshal.AsSpan(controllers))
2324
{
2425
Type[] potentialConflicting = controllers.Where(x => x.Name == controller.Name).ToArray();
2526
if (potentialConflicting.Length > 1)

src/Umbraco.Cms.Persistence.EFCore/Locking/SqlServerEFCoreDistributedLockingMechanism.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace Umbraco.Cms.Persistence.EFCore.Locking;
1515

16-
internal class SqlServerEFCoreDistributedLockingMechanism<T> : IDistributedLockingMechanism
16+
internal sealed class SqlServerEFCoreDistributedLockingMechanism<T> : IDistributedLockingMechanism
1717
where T : DbContext
1818
{
1919
private ConnectionStrings _connectionStrings;
@@ -58,7 +58,7 @@ public IDistributedLock WriteLock(int lockId, TimeSpan? obtainLockTimeout = null
5858
return new SqlServerDistributedLock(this, lockId, DistributedLockType.WriteLock, obtainLockTimeout.Value);
5959
}
6060

61-
private class SqlServerDistributedLock : IDistributedLock
61+
private sealed class SqlServerDistributedLock : IDistributedLock
6262
{
6363
private readonly SqlServerEFCoreDistributedLockingMechanism<T> _parent;
6464
private readonly TimeSpan _timeout;

0 commit comments

Comments
 (0)