Open
Description
the routine you're updating is starting to look a little complicated, so maybe soon it's time to attempt to refactor, but without tests, i wouldn't be comfortable. even one trivial test would encode the special case/scenario that you encountered.
Originally posted by @williballenthin in #1897 (comment)
We should have more tests to encode all the various API patterns we support.
Refactoring of the existing routines and maybe introducing separate functions for .NET vs. native vs. others may make sense as part of that.