Skip to content

Conversation

@mandel-macaque
Copy link
Contributor

When working on https://github.com/xamarin/maccore/issues/940 we noticed
that clone the array would be a better approach.

The CFArrayCreateCopy add some nice things:

  • The pointer values from theArray are copied into the new array.
  • The values are also retained by the new array.
  • The count of the new array is the same as theArray
  • The new array uses the same callbacks as theArray. [IMPORTANT]

With this in, we can have a better fix for https://github.com/xamarin/maccore/issues/940

When working on https://github.com/xamarin/maccore/issues/940 we noticed
that clone the array would be a better approach.

The CFArrayCreateCopy add some nice things:

* The pointer values from theArray are copied into the new array.
* The values are also retained by the new array.
* The count of the new array is the same as theArray
* The new array uses the same callbacks as theArray. [IMPORTANT]

Whith this in, we can have a better fix for https://github.com/xamarin/maccore/issues/940
Comment on lines +38 to +39
using CFArrayRef = System.IntPtr;
using CFAllocatorRef = System.IntPtr;
Copy link

@ghost ghost Nov 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we name IntPtrs with using statements and not just use IntPtrdirectly for the parmeter types in Clone()? There's other bindings that use IntPtr directly and mention the objc/c type in an inline comment. What's the standard practice?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is easier to read. I would have changed all, but would have increase the diff. It does not change the output result of the binding.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha nice question, but yeah just for readability.

giphy

@monojenkins
Copy link
Collaborator

Build failure
Build succeeded
API Diff (from stable)
API Diff (from PR only) (no change)
Generator Diff (no change)
🔥 Test run failed 🔥

Test results

1 tests failed, 86 tests passed.

Failed tests

  • monotouch-test/watchOS 32-bits - simulator/Debug: Crashed

Copy link
Contributor

@spouliot spouliot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since it's a manual binding it should have a test
e.g. just check that the cloned array has a different handle but the same items (and item's handle)

@mandel-macaque
Copy link
Contributor Author

mandel-macaque commented Nov 12, 2019

@spouliot CFArray is not public. Do you want me to change the internals visibility to be able to write the test?

Reference: https://github.com/xamarin/xamarin-macios/pull/7403/files#diff-040868f3bab7e292496e64762f84a985R43

@spouliot
Copy link
Contributor

@mandel-macaque forgot about that, it will be tested w/CFBundle anyway :)

@spouliot spouliot added the not-notes-worthy Ignore for release notes label Nov 13, 2019
@mandel-macaque mandel-macaque merged commit f613021 into dotnet:master Nov 13, 2019
@mandel-macaque mandel-macaque deleted the clone-cfarray branch November 13, 2019 11:06
mandel-macaque added a commit to mandel-macaque/xamarin-macios that referenced this pull request Nov 13, 2019
When working on https://github.com/xamarin/maccore/issues/940 we noticed
that clone the array would be a better approach.

The CFArrayCreateCopy add some nice things:

* The pointer values from theArray are copied into the new array.
* The values are also retained by the new array.
* The count of the new array is the same as theArray
* The new array uses the same callbacks as theArray. [IMPORTANT]

Whith this in, we can have a better fix for https://github.com/xamarin/maccore/issues/940
mandel-macaque added a commit to mandel-macaque/xamarin-macios that referenced this pull request Nov 13, 2019
When working on https://github.com/xamarin/maccore/issues/940 we noticed
that clone the array would be a better approach.

The CFArrayCreateCopy add some nice things:

* The pointer values from theArray are copied into the new array.
* The values are also retained by the new array.
* The count of the new array is the same as theArray
* The new array uses the same callbacks as theArray. [IMPORTANT]

Whith this in, we can have a better fix for https://github.com/xamarin/maccore/issues/940
mandel-macaque added a commit to mandel-macaque/xamarin-macios that referenced this pull request Nov 13, 2019
When working on https://github.com/xamarin/maccore/issues/940 we noticed
that clone the array would be a better approach.

The CFArrayCreateCopy add some nice things:

* The pointer values from theArray are copied into the new array.
* The values are also retained by the new array.
* The count of the new array is the same as theArray
* The new array uses the same callbacks as theArray. [IMPORTANT]

Whith this in, we can have a better fix for https://github.com/xamarin/maccore/issues/940
@mandel-macaque
Copy link
Contributor Author

@monojenkins backport xcode11.3

mandel-macaque added a commit to monojenkins/xamarin-macios that referenced this pull request Nov 14, 2019
When working on https://github.com/xamarin/maccore/issues/940 we noticed
that clone the array would be a better approach.

The CFArrayCreateCopy add some nice things:

* The pointer values from theArray are copied into the new array.
* The values are also retained by the new array.
* The count of the new array is the same as theArray
* The new array uses the same callbacks as theArray. [IMPORTANT]

Whith this in, we can have a better fix for https://github.com/xamarin/maccore/issues/940
mandel-macaque pushed a commit that referenced this pull request Nov 14, 2019
* [CoreFoundation] CFBundle.GetAll better thread safe.

The initial solution fixed the rance condition in which the index
changed, but that did not guarantee that we would get the correct
bundles. We now clone the CFArray (which also clones the callbacks set
to the array) and iterate over it to make sure Apple does not do evil
tings while we are iteraing.

Better Fixes: https://github.com/xamarin/maccore/issues/940

* [CoreFoundation] Add Clone method for CFArray. (#7403)

When working on https://github.com/xamarin/maccore/issues/940 we noticed
that clone the array would be a better approach.

The CFArrayCreateCopy add some nice things:

* The pointer values from theArray are copied into the new array.
* The values are also retained by the new array.
* The count of the new array is the same as theArray
* The new array uses the same callbacks as theArray. [IMPORTANT]

Whith this in, we can have a better fix for https://github.com/xamarin/maccore/issues/940
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

not-notes-worthy Ignore for release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants