- Notifications
You must be signed in to change notification settings - Fork548
[Network] Improve bindings for NWProtocolMetadata.#6389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
[Network] Improve bindings for NWProtocolMetadata.#6389
Uh oh!
There was an error while loading.Please reload this page.
Conversation
It turns out the NWProtocolMetadata can contain metadata for differentprotocols (Ip/Tls/Tcp). This is important; if someone tries to get a value forone protocol and the metadata is for another protocol, then they invoke thewrath of superior beings who will smite that poor someone with uninitializedmemory.At that point there's not much left but to pray.I don't like to depend on divine intervention, so I've modified the API hereto check if the metadata's protocol is the required type for the native APIwe're calling, and if the check fails, we throw a nice and dependable managedexception.This is a functional breaking change; but if there are any lost souls wholikes to pray, they can always re-implement the P/Invokes themselves and skipthe sanity checks.In addition I've renamed a few properties whose name didn't clearly specifywhich protocol type they operate on.Ref: Apple feedback FB6155967.Ref:https://trello.com/c/1TW0BSKJ/145-fb6155967-nwipcreatemetadata-returns-uninitialized-metadata-in-ios-13
spouliot left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
minor
src/Network/NWProtocolMetadata.cs Outdated
| voidCheckIsTcp() | ||
| { | ||
| if(!IsTcp) | ||
| thrownewInvalidOperationException("This metadata is not Tcp metadata."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
TCP in the text itself
monojenkins commentedJun 20, 2019
Build failure Test results4 tests failed, 87 tests passed.Failed tests
|
monojenkins commentedJun 21, 2019
Build failure Test results16 tests failed, 75 tests passed.Failed tests
|
rolfbjarne commentedJun 21, 2019
Test failures are unrelated |
It turns out the NWProtocolMetadata can contain metadata for different
protocols (Ip/Tls/Tcp). This is important; if someone tries to get a value for
one protocol and the metadata is for another protocol, then they invoke the
wrath of superior beings who will smite that poor someone with uninitialized
memory.
At that point there's not much left but to pray.
I don't like to depend on divine intervention, so I've modified the API here
to check if the metadata's protocol is the required type for the native API
we're calling, and if the check fails, we throw a nice and dependable managed
exception.
This is a functional breaking change; but if there are any lost souls who
likes to pray, they can always re-implement the P/Invokes themselves and skip
the sanity checks.
In addition I've renamed a few properties whose name didn't clearly specify
which protocol type they operate on.
Ref: Apple feedback FB6155967.
Ref:https://trello.com/c/1TW0BSKJ/145-fb6155967-nwipcreatemetadata-returns-uninitialized-metadata-in-ios-13