Skip to content

Commit

Permalink
Merge branch 'main' into bugfix/204-inconsistent-field-level-validation
Browse files Browse the repository at this point in the history
pwelter34 authored Apr 7, 2024
2 parents 97e4394 + 3f18c1f commit ab914a3
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -101,7 +101,7 @@ If you're using async validation, you can use the `ValidateAsync` method on the
private async void SubmitFormAsync()
{
if (await _fluentValidationValidator!.ValidateAsync())
if (await _fluentValidationValidator!.ValidateAsync())
{
Console.WriteLine("Form Submitted Successfully!");
}
Original file line number Diff line number Diff line change
@@ -227,6 +227,16 @@ private static FieldIdentifier ToFieldIdentifier(in EditContext editContext, in
var indexerValue = int.Parse(nextToken);
newObj = array[indexerValue];
}
else if (obj is IReadOnlyList<object> readOnlyList)
{
// Addresses an issue with collection expressions in C# 12 regarding IReadOnlyList:
// Generates a <>z__ReadOnlyArray which:
// - lacks an Item property, and
// - cannot be cast to object[] successfully.
// This workaround accesses elements directly using an indexer.
var indexerValue = int.Parse(nextToken);
newObj = readOnlyList[indexerValue];
}
else
{
throw new InvalidOperationException($"Could not find indexer on object of type {obj.GetType().FullName}.");

0 comments on commit ab914a3

Please sign in to comment.