DataTableRow's CopyTo throws #625
Unanswered
zdenek-jelinek
asked this question in
Q&A
Replies: 1 comment
-
Sounds like a bug to me! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
DataTableRow.CopyTo throws the following exception:
As someone who occasionally processes tables row by row (e.g. to dynamically validate xlsx export data against gherkin spec), it's very helpful for me to use LINQ methods such as ToList. Unfortunately, these tend to call ICollection::CopyTo internally if they manage to downcast the source collection.
This can be reproduced with code such as
It can be worked around by introducing another iterator such as using
.Select(x => x).ToList()
to avoid the ICollection downcast.Is there a reason for throwing here? Both
KeyValuePair<,>
andstring
are immutable so I think it should be safe for the table's structure to copy the data outside. Is this perhaps an omission? Would you be open to a PR to change this? Or could we possibly change the exception message to better describe the error, if it is intended?Beta Was this translation helpful? Give feedback.
All reactions