You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have identified an issue with Blazored/FluentValidation following the migration to .NET 8.0 and C# 12. Since we work with Fluxor, all our data is immutable. Moreover, we use the IReadOnlyList<> interface for lists throughout.
With the new C# 12 syntax for list initialization, a "standard" list/array is no longer created; instead, a type named "<>z__ReadOnlyArray" is generated. This new type neither possesses an Item property nor can it be converted into an object array. The code in the ToFieldIdentifier method within the EditContextFluentValidationExtensions class throws an exception as a result.
The following example demonstrates the problem (Note: the code must be compiled with C# 12, and we have tested with Visual Studio 17.9.0):
List<string> list = ["1", "2"];
IReadOnlyList<string> readonlyList = ["1", "2"];
var listHasItemProperty = list.GetType().GetProperties().Any(x => x.Name == "Item");
var readOnlyListHasItemProperty = readonlyList.GetType().GetProperties().Any(x => x.Name == "Item");
Console.WriteLine(listHasItemProperty); // True
Console.WriteLine(readOnlyListHasItemProperty); // False
var objects = readonlyList as object[];
Console.WriteLine(objects != null); // False
We have identified an issue with Blazored/FluentValidation following the migration to .NET 8.0 and C# 12. Since we work with Fluxor, all our data is immutable. Moreover, we use the IReadOnlyList<> interface for lists throughout.
With the new C# 12 syntax for list initialization, a "standard" list/array is no longer created; instead, a type named "<>z__ReadOnlyArray" is generated. This new type neither possesses an Item property nor can it be converted into an object array. The code in the
ToFieldIdentifier
method within theEditContextFluentValidationExtensions
class throws an exception as a result.The following example demonstrates the problem (Note: the code must be compiled with C# 12, and we have tested with Visual Studio 17.9.0):
The following PR resolves the issue #214
The text was updated successfully, but these errors were encountered: