Closed WORMrus closed 2 months ago
@WORMrus Could you please provide a pr for this fix?
@sergeyshaykhullin Sorry, took me some time to notice a notification. Sure, I will. Seems like an easy enough fix.
@sergeyshaykhullin please see https://github.com/appany/AppAny.HotChocolate.FluentValidation/pull/112
The problematic line: https://github.com/appany/AppAny.HotChocolate.FluentValidation/blob/770b7ad4f5e7d6238b8a5fe2f99d5ff77a86665d/src/ValidationDefaults.cs#L219
The call to
GetServices()
returns anIEnumerable<object?>
, It would not be correct to assume that the underlying type is an array (object[]
). While the default DI container indeed returns an array, this may not hold in all cases.Real-life example: I was looking into Wolverine for messaging, which requires you to use Lamar. Lamar returns a
List<T>
instead of an array which results in a runtimeInvalidCastException
.