This turned into a rather involved exercise, because the
MidiThruConnectionParamsStruct struct had several array fields that needed
marshalling to work.
The changes include:
* Unwrap the array fields with MarshalAs attributes to be individual fields
instead.
* Write a number of tests to ensure the changes work.
* Fix an overflow issue found by the tests for the Controls array if trying to
set to an array with more than 65535 elements.
* Fix an overflow issue found by the tests for the Maps array if trying to set
to an array with more than 65535 elements.
* Fix an issue found by the tests where we wouldn't deserialize the Maps array
correctly from a byte array / NSData if the Maps array had more than 1
element.
* Fix a consistency issue found in the tests where deserializing a serialized
structure doesn't yield the same result.
* In particular this happens with the ChannelMap property: behavior has
changed a little bit where setting the ChannelMap to an array with fewer
than 16 elements (including a null array) will not return the same array
anymore, but instead an array with 16 elements, where the extra elements
are all 0. I've also made the ChannelMap property non-nullable, since
the nullability state isn't serializable into the underlying struct.
Contributes towards #15684.
Fix sending MidiPacket when MidiPacket has been created using a pointer to a byte[] rather than a byte[] passed as a reference.
MidiPacket.bytes used to be initialized to null, but that changed in a null-refactoring. Unfortunately code that dependend on the initial value being null wasn't updated, so the code regressed. Here we revert the old behavior by making the MidiPacket.bytes field nullable
Also add a test to make sure we don't regress this code again.
---------
Co-authored-by: Alex Soto <alex@alexsoto.me>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Fixesxamarin/maccore#658
When a MidiThruConnection is created but for some reason is not disposed
the system keeps it alive even between app/simulator restarts, if you want
to clean the connections you must reset contents and settings from simulator.
In order to avoid this test from failing randomly and since the intent of the
test is to check if `MidiThruConnection.Find` works we change the assert to
`>= 2` since this is at least the number of connections we expect.