C
C#5mo ago
Gramore

Co-varient array warning.

I'm getting a warning about co-variant conversion from ExpressionElementSyntax[] to CollectionElementSyntax[] when using AddElements() on a CollectionExpressionSyntax. Isn't this required by the API since CollectionElementSyntax is abstract? --- For context: - This is a resharper warning - As far as I understand it this is safe since the array is just used in an AddRange() anyway - Full message: Co-variant array conversion from ExpressionElementSyntax[] to CollectionElementSyntax[] can cause run-time exception on write operation
1 Reply
reflectronic
reflectronic5mo ago
yes, this would seem to be fine, since the potential problem is only when the casted array is written to AddElements is just reading the elements from the casted array so there is no problem the warning can be ignored/suppressed