Skip to content

Commit

Permalink
OCC-237: Checkout page throws exception because of non awaited async …
Browse files Browse the repository at this point in the history
…method (#432)

* Waiting for numeric order result

* Refactoring to comply with VSTHRD003

#VSTHRD003: Avoid awaiting or returning a Task representing work that was not started within your context as that can lead to deadlocks.
  • Loading branch information
wAsnk authored Apr 29, 2024
1 parent 0bdc093 commit 4c2a29b
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,21 @@ public async Task<IEnumerable<string>> GetFieldShapeTypesAsync(
string displayType = CommonContentDisplayTypes.Detail)
{
var typeDefinition = await _contentDefinitionManager.GetTypeDefinitionAsync(contentItem.ContentType);

var partsOrders = new Dictionary<string, int>();
foreach (var part in typeDefinition.Parts)
{
partsOrders.Add(part.Name, await GetNumericOrderAsync(part));
}

return typeDefinition
.Parts
.SelectMany(part =>
part.PartDefinition.Fields.Select(field => new
{
PartName = part.Name,
FieldName = field.Name,
PartOrder = GetNumericOrderAsync(part),
PartOrder = partsOrders[part.Name],
FieldOrder = GetNumericOrder(field),
}))
.OrderBy(item => item.PartOrder)
Expand Down

0 comments on commit 4c2a29b

Please sign in to comment.