* NSDataDetector
* Add constructor found in header. No idea where the commented-out
constructor came from, it's not in the header, so I removed it.
* Add overloads that take NSTextCheckingType in addition to
NSTextCheckingTypes. Apple's API take NSTextCheckingTypes, but all the
documentation and samples say that you're supposed to pass one or more
or'ed NSTextCheckingType values, so support that as well without casting
between enums.
* NSRegularExpression
* GetMatches had the wrong return type, so add a GetMatches2 that does it
right. Also add a test to make sure it's really right.
* Bind 'regularExpressionWithPattern:options:error:' with a static method.
There's a corresponding constructor, but constructors returning out
NSError parameters isn't the nicest API (when the NSError is important),
so add the static method as well.
* Add a missing [NullAllowed] on FindFirstMatch's return value.
* NSRegularExpressionOptions
* Add missing enum value.
Fixes https://github.com/xamarin/xamarin-macios/issues/5881.
NSNotificationCenter is thread-safe, so that observers can be added and
removed in multiple threads simultaneously.
Unfortunately our own helper code wasn't, so make sure to fix that by locking
around all accesses to the observer list.
And add a test case as well.
- Fixes#4441: [generator] Binding with return value of Class [] do not do the right thing
(https://github.com/xamarin/xamarin-macios/issues/4441)
- Turns out the logic to put INativeObjects into NSArrays was already in place. We simply needed to add the missing (IntPtr handle, bool owns) overload to `Class`.
- Uncommented AppKit `registeredImageRepClasses` since it was using `Class []`. Tested locally and it works fine.
- Reimplemented `Foundation`'s `NSSecureUnarchiveFromDataTransformer` and its test which were also using `Class []`.
* Fix many version checks to be based on Xcode version instead of iOS version.
* Added/fixed a few expected values according to platform version to match behavior in older macOS versions.
* [tests] Determine at runtime instead of compile time whether LinkAll is enabled. Fixes#3812.
This way we can remove the LINKALL define, which also means nobody can forget
to define it when building using LinkAll.
https://github.com/xamarin/xamarin-macios/issues/3812
Repetitive calls to `NSNull.Null.Handle`, e.g. from `NSArray.UnsafeGetItem<T>`,
means several (one by item), costly, calls into ObjC code - but it always
return the same (native) singleton.
This manually cache the managed `NSNull.Null` static value, once it's
initialized the first time, so future calls won't have the performance
penalty.
https://github.com/xamarin/xamarin-macios/issues/3544
Add a 'register-protocols' optimization that:
Improves static registrar to:
* Generate a new table of protocol -> managed wrapper type. This is required
to find the wrapper type without having the `[Protocol]` attribute around.
* Make the generated code implement protocols from [Adopts] attributes. This
makes it possible to link away the `[Protocol]` attribute, because the
native implementation of `conformsToProtocol:` does the right thing (we
might even be able to link away our complete `ConformsToProtocol` logic when
we remove the dynamic registrar).
Improves linker to:
* Not mark protocol interfaces by the mere virtue of having a type that
implements them. This is implemented by not marking protocol interfaces when
they're implementing a class, but instead when a method implementation is
found to implement a method from a protocol interface.
* Mark the wrapper type for protocols (this allows us to remove the Protocol
attribute, since that's the link between the protocol and its wrapper type).
* Remove the [Protocol], [ProtocolMember] and [Adopts] attributes (but only if
optimizing protocols).
The static registrar still needs some of the information linked away, so a few
changes are required to make it available post linker.
Benchmark
---------
I've compared the size of entire apps built for device:
|test | Before | After | Diff | % |
|:-----------------------------|-------:|-------:|-------:|------:|
|[monotouch-test/Debug][1] | 101mb | 100mb | -888kb | -0.9% |
|[monotouch-test/Release][2] | 99.2mb | 95.4mb | -830kb | -0.9% |
|[minimalistic app/Debug][3] | 10.8mb | 10.4mb | -443kb | -4.1% |
|[minimalistic app/Release][4] | 4.7mb | 4.55mb | -157kb | -3.3% |
[1]: https://gist.github.com/rolfbjarne/0181ab8abe436c34cf4ee68ecfb8cd18#monotouch-test-debug
[2]: https://gist.github.com/rolfbjarne/0181ab8abe436c34cf4ee68ecfb8cd18#monotouch-test-release
[3]: https://gist.github.com/rolfbjarne/0181ab8abe436c34cf4ee68ecfb8cd18#minimal-xi-app-debug
[4]: https://gist.github.com/rolfbjarne/0181ab8abe436c34cf4ee68ecfb8cd18#minimal-xi-app-release
The original, now obsoleted, `LocalizedString` API returned a .net
`string` which does not work in most cases.
Different versions of iOS seems to return different (public or internal)
subclasses of `NSString` that are understood by other API (like NSString
`localizedStringWithFormat:`) for further customization.
Our logic to convert NSString to string is correct but it cannot
recreate the custom, required subclass to continue the localization.
So the new API return an `NSString` publicly (which is actually a
subclass) that can do the required job.
Adding a test in monotouch-test is presently blocked by #3265 [2]
[1] https://bugzilla.xamarin.com/show_bug.cgi?id=41292
[2] https://github.com/xamarin/xamarin-macios/issues/3265
* Add tests for new (and old) NSBundle API and adjust old ones since adding a Base.lproj directories changes things
* Add localization to xammac_tests since it shares the same, updated tests
and ensure the temporary `NSString` instance is disposed asap.
Found will debugging something else. Unit tests added to confirm there
is no behavior change when the API are used.
* [MSBuild] Do not set CFBundleDevelopmentRegion if not present.
This is a complicated fix. This is a regression introduced by Apple.
CFLocaleCopyCurrent(), used in the iOS code, will return the value of
the application's CFBundleDevelopmentRegion Info.plist key if all of the
following conditions are true:
* CFBundleDevelopmentRegion is present in the Info.plist
* The CFBundleDevelopmentRegion language is in the list of preferred
languages on the iOS device, but isn't the first one
* There are no localized resources (i.e. no .lproj directory) in the app
for the first preferred locale
This differs from iOS 10 where the presence of the
CFBundleDevelopmentRegion key had no effect.
Note that if the CFBundleDevelopmentRegion key is not present at all,
CFLocaleCopyCurrent() always returns the first preferred locale as it
did in iOS 10.
We are adding the key by default in the plist of the applications which confuses users since they do not see the key in the .plist added by the template. This commit removes it to be more explicit and help users understand the behaviour.
Hopefully third time's the charm...
Don't do date math (adding hours) to a local datetime, since DST *will* muddy
the waters and prove that 1=2.
Instead convert the date we want to calculate on to UTC, which should be DST-agnostic.
I've tested this by running the test for every hour during the next 10 years,
so that should cover mostly everything (although I'm still waiting for the
Delorean I ordered to be able to test both in the future and the past).
Previous attempts:
0442cdf9c05caddb3571
Should fix https://github.com/xamarin/maccore/issues/573.
In 0442cdf9c0 the `now` variable was changed to
be a UTC date, but unfortunately the code that compares it to a local date
(NSDate.Now) wasn't updated.
Only year/month/day values were compared, which meant the test would fail if
run when UTC and local time didn't represent the same date (and conversely
would pass if the UTC and local date was the same date, which is why the
changed did not fail the PR test run: the PR was tested during the 19 hours of
the day when EST and UTC represent the sam date).
Fix this by converting the UTC `now` to NSDate instead of using NSDate.Now.
This has the additional benefit of also fixing a (much smaller) race
condition: if midnight occurred just between calculating `now` and NSDate.Now,
the test would also fail.
At 2:00 AM on November 5h 2017, winter came to our bots in Boston.
This meant that between 2:00 and 3:00 AM, subtracting 1h from the current
time yielded a time difference of 2h.
This was caught by our observant tests:
[FAIL] CalendarTest.DateComponentsTest : b hour
Expected: 1
But was: 2
To avoid such issues next time this test happens to run during this single
hour of the entire year that causes problems, change the test to use time
calculcation using UTC instead.
The explicit operator did all it's math using `long` (the internal
representation for DateTime) so the fractional part of the NSDate was
lost. E.g.
> original: 530499149.239266
> roundtrip: 530499149.0
However even when using `double` computations we're still losing some
precision - parts just can be held in the `long` (Ticks) representation
of DateTime.
> original: 530499149.239266
> roundtrip: 530499149.23927
Reference:
https://bugzilla.xamarin.com/show_bug.cgi?id=32022
* [monotouch-test] Disable EmptyNib tests due to Xcode9 no longer builds nibs if deployment target < 7.0
EmptyNib.xib : ibtool error : Compiling IB documents for earlier than iOS 7 is no longer supported.
* [monotouch-test] Fixt CalendarTest.TestEnumerateDates
It seems that NSCalendar.CurrentCalendar.EnumerateDatesStartingAfterDate
won't stop enumerating unless `stop` is set to `true`.
* [Tests] Add CheckXcodeVersion support for Xcode 9
* [introspection] Avoid introspection to crash with Xcode 9 Beta 1
* [monotouch-test] bring back LogicalName removal from monotouch-test.csproj
The existing code was cheating and returned a managed only instance with a `nil` handle. That was fine in many cases but some API (e.g. UISegmentedControl) don't like that (i.e. don't react like a normal, empty NSArray was supplied). It's also the right thing to do since the current behaviour is not guaranteed to remain identical on future updates of the OS.
Unit tests updated.
Trello: https://trello.com/c/mKsUDti8
This adds a new overload to our Notifications class
Current:
public static NSObject ObserveDidStart (EventHandler<NSNotificationEventArgs> handler)
New overload:
public static NSObject ObserveDidStart (NSObject objectToObserve, EventHandler<NSNotificationEventArgs> handler)
This allows our users to have single object subscription to our
easy to find notifications.
Also this commit adds an Advice attribute encouraging to use the
Notifications class instead of the NSString based notifications
https://bugzilla.xamarin.com/show_bug.cgi?id=37175
NSUrlSession's Create*Task methods may return an object of the wrong
type (NSUrlSessionTask instead of NSUrl[Data|Download|Upload]SessionTask),
so we need to bypass our type check when creating the managed object,
otherwise we end up throwing InvalidCastExceptions randomly. We will
return the type that is declared on the headers so if the native side
returns a cat and headers says it barks we'll we make it bark :).
This is a static selector that needs to be overridden, which is not the
usual pattern in C#. We re-define it using [New] on subclasses.
Unit tests added for all NSDimension subclasses.
reference:
https://bugzilla.xamarin.com/show_bug.cgi?id=43444
- Split in two to ease review;
- Unit tests added for NSUrlSessionTaskMetrics and
NSUrlSessionTaskTransactionMetrics as they don't respond to selectors
like expected (but just like other NSUrlSession* types)
* Mostly missing checks
* FontTest: Apple never fixed that and the way we link now, without
dlsym, makes the test crash
dyld: lazy symbol binding failed: Symbol not found: _CTFontCreateWithFontDescriptorAndOptions
Referenced from: /var/mobile/Applications/6025D222-F50E-46E0-8BF5-9C45D4C7DACB/monotouchtest.app/monotouchtest
Expected in: /System/Library/Frameworks/CoreText.framework/CoreText
Fix issues with monotouch-tests with beta2
* TLSMaximumSupportedProtocol returns Unknown, which also means default,
instead of SslProtocol.Tls_1_2
* Setting NSZone.Name crash the app
* The MDLMesh tests are broken in a different way than beta1
* [callkit] Disable CTCallCenter default ctor as it breaks introspection
> [FAIL] Default constructor not allowed for CoreTelephony.CTCallCenter : SIGILL
The exception, that we catch, puts the process in an unstable state.
This cause weird results and crash later (wrong dispatch queue on main
thread) when testing MapKit.
Crashed Thread: 0 tid_a07 Dispatch queue: CTCallCenter
Exception Type: EXC_BAD_ACCESS (SIGABRT)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000004
Exception Note: EXC_CORPSE_NOTIFY
VM Regions Near 0x4:
-->
__TEXT 0000000000097000-00000000004d2000 [ 4332K] r-x/rwx SM=COW /Users/USER/Library/Developer/CoreSimulator/Devices/9446B344-62A2-42A8-A8EE-9FE7AC6BA5C8/data/Containers/Bundle/Application/81183608-DADF-4226-B7FE-4B43759D679A/introspection.app/introspection
Application Specific Information:
BUG IN CLIENT OF LIBDISPATCH: dispatch_barrier_sync called on queue already owned by current thread
abort() called
CoreSimulator 278 - Device: iPhone 5 - Runtime: iOS 10.0 (14A5297c) - DeviceType: iPhone 5
Some beta2 adjustments (removals) to get green tests and be able to merge it so bindings of beta2 can start
* [tests] NEFlowMetaData conformance to NSSecureCoding and NSCopying is new in beta2 (and check fails on OSX 10.11)
* [uikit] Add [UIScrollView|UITableViewController].refreshControl to fix monotouch-test build
UIRefreshControlHosting was removed in beta2 but we still need the
refreshControl property on UIScrollView and UITableViewController
to build monotouch-test
* [Foundation] NSUbiquitousKeyValueStore is not available on watchOS.
Fixes an issue found by the introspection tests when running on a
watchOS device.
* [monotouch-test] Fix watchOS build with regards to NSUbiquitousKeyValueStore changes.
Also use https instead of http to avoid a network roundtrip
(since http://www.xamarin.com just redirects to https).
This will hopefully fix this random test failure:
[FAIL] UrlSessionTest.CreateDataTaskAsync : CreateUploadTask a
https://bugzilla.xamarin.com/show_bug.cgi?id=41343
* NSDictionary<TKey, TValue>.FromObjectsAndKeys keys and values are twisted up
* Fixed it in XAMCORE_4_0
* Obsoleted the 2 existing methods
* introduced FromObjectsAndKeys (TValue [] objects, TKey [] keys, nint count)
* Added unit tests with different types for TKey and TValue