AVMediaTypeTimedMetadata has been obsoleted since iOS 6 but was totally
removed (returns null) in iOS 12.
Adjust test and provide a (better) deprecation warning for developers.
We have a test for CGFunction, and in iOS 12 the behavior changed where
previously the CGFunction was invoked immediately when rendering, it's now
retained and only called later.
This is troublesome for the test, because it disposes the managed CGFunction
when it thinks it's completed. Since the function is invoked way later, the
test now crashes. Ops.
The obvious fix is to change the test to dispose the CGFunction later. This
falls flat when finding out that "later" is undetermined. Native code retains
the CGFunction, and can do whatever it wishes with it until it's released, and
there's no way to know when that is.
OK: what about not disposing the CGFunction, and letting the GC do its job?
This also falls flat, because there's a circular reference between the native
CGFunction and the managed wrapper, preventing any of them from being released
automatically by the GC. The only way to break the circular reference is to
dispose the managed wrapper.
So, can we fix the circular reference? Unfortunately not, because we can't
monitor the native CGFunction's retain count, which is required in order to
switch the native->managed link between weak and strong according to the
retain count.
This leaves one solution (that I could come up with at least): make sure
everything works fine after disposing the managed wrapper.
This involves a few things:
* Only break the native->managed connection (the 'gch' GCHandle) when the
native CGFunction is freed. This is accomplished by using the API provided
by Apple for exactly that purpose (the 'release' callback field in the
'CGFunctionCallbacks' struct).
* Use a static variable for the 'CGFunctionCallback' struct and its contents.
This solves another potential problem: the GC could have collected the
delegate to the 'EvaluateCallback' function at any point.
* Don't null out the 'evaluate' delegate in Dispose. This leaves the user with
no way to break a potential circular reference through that delegate (since
it will never be null), so provide a property that makes it possible for
users to explicitly null out the delegate ('EvaluateFunction').
* Only call the 'evaluate' callback if it's not null.
This also has the additional advantage that test (and any customer code
running into the same issue) works without modifications.
Some of the tests fail because the assert is looking at the wrong iOS
version. Looking at the API definitions:
* UIStackView - Available in iOS 9, not iOS 8.
* AudioServicesPlayAlertSoundWithCompletion - Available in iOS 9, not
iOS 8.
All the other tests reported in the issue pass.
Issue: https://github.com/xamarin/xamarin-macios/issues/4437
* [CoreGraphics] Add CGPDFArray.Get* overloads that take a nint index, since the CGPDFArray.Count property returns nint.
This makes the following code work:
for (var i = 0; i < array.Count; i++)
array.GetInt (i, ...)
* Don't add [MonoPInvokeCallback] to Mac code.
* [CoreGraphics] Rename CGPDFArray.ApplyBlockCallback to ApplyCallback.
Since the fact that the method is implemented using a block is not relevant
for managed code.
This also makes the method named like an equivalent method in CGPDFDictionary.
* [CoreGraphics] Change CGPDFArray.Apply to take an 'object' as the info parameter instead of IntPtr.
This makes it nicer for managed code.
* [CoreGraphics] CGPDFArray.Apply: resolve the iterated object to the actual CGPDFObject type.
* [CoreGraphics] Add an CGPDFDictionary.Apply overload that resolves the iterated object to the actual CGPDFObject type.
This method was previously only available in Classic, so I just reintroduced
it with a few changes to make the API nicer (which isn't a breaking change
since we're not building Classic anymore).
* [tests] Add test for CGPDF types.
* [tests] Don't run the new tests unless the SDK was part of Xcode 10
* [CoreGraphics] Add first batch of Xcode10 APIs, added an enum that we did not surface before
* [xcode10] CoreGraphics support
* Fix whitespace/formatting and add comma after last enum value.
* Make CFPropertyList follow normal INativeObject creation pattern.
* Make CFPropertyList.AsData return the error as a tuple.
* Fix CFPropertyList.AsData to not leak.
* CFPropertyList.Value: use Runtime.GetNSObject so that we don't accidentally create duplicate wrappers for the same native object.
* [CoreGraphics] Update to beta 5.
* Update xtro definitions.
* Add tests.
* Don't compare value type with null.
* Use PascalCase for named return tuples.
* [CoreFoundation] Make CFPropertyList enums native and fix code accordingly.
* [tests] Fix fetching 64-bit int to actually fetch a 64-bit int and not a nint.
* [tests] Teach introspection's ApiCMAttachmentTest about CFPropertyList.
The default `Message` property is not every helpful. Better information
is available inside the `Error` property but it's not general (nor cross
platform) when dealing with exception.
Include unit tests (on an existing test checking NSError values)
https://github.com/xamarin/xamarin-macios/issues/4133
Unify the code to detect frameworks that aren't supported in the simulator (we
had switches in two places, now this data is stored per framework).
Also remove some of the Metal frameworks for some of the platforms from these
lists (since they're now available in the simulator in some cases), which
fixes#4422.
It also seems CoreAudioKit is now available in the simulator (it wasn't in the
first Xcode 7 beta, but apparently added in a later beta. This made our
exclusion incorrect, but we never noticed).
https://github.com/xamarin/xamarin-macios/issues/4422
- Updated some ARReferenceObject APIs based on their (better) Swift names. Breaking changes but on new APIs.
- Update ARReferenceObjectTest for device (center and extent have real values on device).
- Reuploaded an arobject file from Beta 3 just in case because of: "ARReferenceObject and ARWorldMap data generated using iOS 12 beta 2 or earlier isn’t compatible with beta 3 or later. Please rescan your objects to generate new ARReferenceObject and ARWorldMap data."
[tests] Run Xamarin.Mac tests on Mojave, and add more Xamarin.Mac tests.
* Add more Xamarin.Mac tests: introspection, link sdk, link all and xammac_tests.
* Fix TextureAtlasTest.Empty to not crash due to Apple not liking null callbacks. (#4003)
* Run Xamarin.Mac tests on Mojave as well, even though the build OS is an earlier OS (High Sierra).
* 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.
* Convert it into a MM8027/MT8027 error (with documentation).
* Add information about the selector and managed method that triggered the error.
Now the problem reported in issue #4254 shows up as:
> ObjCRuntime.RuntimeException: Failed to marshal the Objective-C object 0x7f8080412810 (type: UIView). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance (because the type 'UIKit.UIView&' does not have a constructor that takes one IntPtr argument).
> Additional information:
> Selector: popoverController:willRepositionPopoverToRect:inView:
> Method: UIKit.UIPopoverController+_UIPopoverControllerDelegate.WillReposition(UIKit.UIPopoverController, CoreGraphics.CGRect ByRef, UIKit.UIView ByRef)
instead of just:
> ObjCRuntime.RuntimeException: Failed to marshal the Objective-C object 0x7f8080412810 (type: UIView). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance (because the type 'UIKit.UIView&' does not have a constructor that takes one IntPtr argument).
which makes it much easier to understand, track down, and fix/work around,
both for customers and ourselves.
* [ObjCRuntime] Make Class.GetHandle not handle byref types. Fixes#4254.
This is a regression between d15-6 and d15-7: it's an unindented consequence
of the changes required to link away the dynamic registrar.
This unindented consequence is non-obvious: it made Class.GetHandle
successfully look up byref types, since we're now using metadata tokens to
look up a Class from the managed Type, and it turns out the metadata tokens
are the same for byref types as the corresponding non-byref type, so
Class.GetHandle treats them identically.
This was not the behavior for Class.GetHandle in d15-6, and other code relied
on this behavior (in particular calling isKindOfClass: in Runtime.GetNSObject
with a nil class returns false, and we'd end up in a different code path that
would not try to create the managed peer with a byref type).
So make sure Class.GetHandle doesn't change its behavior compared to d15-6 by
special-casing byref types to return IntPtr.Zero.
Fixes https://github.com/xamarin/xamarin-macios/issues/4254.
* Move byref check earlier to get identical behavior when the dynamic linker is optimized away.
Also add checks for pointer and array types for the same reason.
Creating a new NSString doesn't always lead to creating a new NSString, which
will obviously cause trouble.
The scenario is:
* An NSString with the value @"Bye" is added to an NSDictionary, with the same
string as both the key and the value.
* The (managed) string indexer is used to try to get the value back. The
string indexer would call 'new NSString ("Bye")', which would create a new
managed NSString, and maybe a new native NSString (or maybe it would re-use
an existing NSString). Then the handle of this NSString would be passed to
the native API, and the same handle would come back as the result (since the
same string is both the key and the value). We'd call Runtime.GetNSString on
the returned handle, get back the same managed instance that was created
just before the call to the native method. Finally, just before returning
this managed instance from the indexer, we'd dispose it... since it was
created in a 'using' block. Then we'd return a disposed NSString object from
the indexer. Ops.
The fix is to not create a managed wrapper for the NSString handle we need to
pass to the native API, but create and free the native NSString object without
using a managed wrapper.
I obsoleted `GetProjectPoint` in favor of `Project` because of the introduction of `Unproject` (which made me realize the naming was wrong) and based on the API doc https://developer.apple.com/documentation/arkit/arcamera/2923538-projectpoint?language=objc.
The `CGPoint` returned is the projection of a point. An other naming option would have been `GetProjectedPoint` but I think `Project` is closer to the original and clear enough. You project/unproject something onto something else and you get the projection back.
* Bump to use Xcode 10 beta 1
* Update Versions.plist
* Add a dependency on Xcode 9.4.
* [msbuild] Fix build with Xcode 10 beta 1. (#4182)
Many years ago (in Xcode 7 according to code comment)
Developer/Platforms/iPhoneOS.platform/Developer/usr disappeared, and we coped
by looking at Developer/usr instead (and also the subsequent code to locate
the bin directory was based on the location of the usr directory).
Developer/Platforms/iPhoneOS.platform/Developer/usr reappeared in Xcode 10
beta 1, but it seems useless (for one it doesn't contain a bin directory), so
in order to try to keep things sane don't look for this directory in Xcode 10
and instead go directly for Developer/usr (which is what we've been using as
the usr directory for years anyway).
Fixes this problem when building apps with Xcode 10 beta 1:
/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/Xamarin.iOS.Common.targets(626,3): error : Could not locate SDK bin directory [/Users/rolf/Projects/TestApp/test-app.csproj]
* [runtime] Build 32-bit mac executables using Xcode 9.4.
* [mtouch] Work around broken tvOS headers in Xcode 10 beta 1.
* [mtouch] Work around build problem with Apple's simd headers in Objective-C++ mode.
* Use version-agnostic paths to sdk directories.
* [tests][xtro] Add todo files (from unclassified) and adjust ignore files to avoid errors
* [macos][security] Re-enable SSL[Get|Set]AlpnProtocols. Fixes#4001 (#4022)
* [macos][security] Re-enable SSL[Get}Set]AlpnProtocols. Fixes#4001
This was fixed in macOS 10.13.4
https://github.com/xamarin/xamarin-macios/issues/4001
* [tests][monotouch-tests] Disable a few test cases (one crasher, other failures). Causes to be verified later
* [xharness] Fix permission dialog suppression in Xcode 10.
* [xharness] Ignore 32-bit macOS tests by default.
* [tests] Execute mmp regression tests with Xcode 9.4 since many of them are 32-bit and needs porting to 64-bit.
* [mmptest] Ignore 32-bit XM tests if we don't have a 32-bit-capable Xcode.
* [registrar] Add workaround for broken headers in Xcode 10 beta 1 (radar 40824697).
* [mtouch] Restrict another workaround for an Xcode 10 beta 1 bug to a specific Xcode version to remove it asap.
* [tests] Fix some protocol changes (public or not) find by introspection tests
* [tests][intro] Fix DefaultCtorAllowed failures
* [Intents] Obsolete several Intents classes in watchOS.
Several existing Intents classes have been marked as unavailable in watchOS in
the headers in Xcode 10 beta 1, and corresponding tests are now failing.
So obsolete the managed wrapper types, and fix tests accordingly.
* Fix xtro wrt previous Ietents/intro changes
* [tests] Minor adjustments to mtouch tests to work with Xcode 10.
* [msbuild] Update tests to cope with additional files produced by the Core ML compiler.
* [msbuild] Xcode 10 doesn't support building watchOS 1 apps, so show a clear error message explaining it.
Also update tests accordingly.
* [coreimage] Stub new filters and exclude ?removed? ones from tests
* Update GameplayKit and SpriteKit NSSecureCoding _upgrade_ and fix other non-public cases (in tests)
* [tests] Ignore some GameKit selectors that don't respond anymore (but seems to be available, at least in header files)
* [tests] Fix intro 32bits testing for filters resutls
* [msbuild] Slightly change error message to be better English.
* [Compression] Ensure we use the correct lonking flags for older versions. Fixes#4129.
Libcompresison was added after iOs 9.0, TvOS 9.0, Mac 10.11 and Watch
2.0. We want to use weak in those older platforms.
Fixes issue https://github.com/xamarin/xamarin-macios/issues/4129
Change WeakReferenceTest.WeakTest so that it doesn't fetch values that should
be garbage collected on the main thread.
Doing so on the main thread may cause those values to stay in registers as
temporary values, thus preventing the garbage collector from collecting them.
Instead do the fetching in a background thread, whose stack won't exist
anymore once it's finished.
Fixes this test failure when running on watchOS device in release mode:
[FAIL] WeakReferenceTest.WeakTest : 't.Obj4' should be null
The reason it only happens on watchOS in release mode, is probably because
LLVM puts temporary values in different registers than Mono's AOT compiler
does.
Change test to verify that all preferred localizations are in the list of
available localizations (instead of hardcoding an expected result of 'en').
This makes the TestPreferredLocalizations work if the device language is 'es',
in which case the preferred language between 'en' and 'es' is obviously 'es'.
* [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
* [monotouch-tests] Adds mono's WeakAttribute tests
* Embrace watchOS
Unfortunately this revealed that WeakAttribute is not working for watchOS
* Port mono's WeakAttribute test to our test runner
Test Ported:
5bdaef7e5f/mono/tests/weak-fields.cs
* Fix object leaks and implement suggested approach from 4b9ade0c59
* Remove debug spew and fix formating on header
* [monotouch-tests] Adds mono's WeakAttribute tests
* Embrace watchOS
Unfortunately this revealed that WeakAttribute is not working for watchOS
* Port mono's WeakAttribute test to our test runner
Test Ported:
5bdaef7e5f/mono/tests/weak-fields.cs
* Fix object leaks and implement suggested approach from 4b9ade0c59
* Remove debug spew and fix formating on header
First there was darkness; no blocks were retained.
Then came the light; and all blocks were retained [1]
Forever.
But all that once is, must one day not be,
and thus the light gave way to darkness,
and blocks were only retained as long as need be [2].
But before there was a balance, there was a crossroad.
In some places the light shone forever,
and all blocks were retained.
In other places there was a balance,
and the light shone only as long as needed.
A desire to unify arose.
Alas, it could not be.
It was a bright and sunny day
When a merge failed [3].
And all blocks were retained. Twice.
Once [here][4] and once [there][5].
For many years we could not see.
Until a dark and rainy night,
when an awareness arose.
And the desire to unify the balance could finally be fulfilled.
[1]: 6efca92acb
[2]: a22f877539
[3]: befa0477cf
[4]: 5158a3c001/src/ObjCRuntime/Runtime.cs (L858)
[5]: 5158a3c001/runtime/runtime.m (L2091)
* [ObjCRuntime] Don't double-retain blocks.
First there was darkness; no blocks were retained.
Then came the light; and all blocks were retained [1]
Forever.
But all that once is, must one day not be,
and thus the light gave way to darkness,
and blocks were only retained as long as need be [2].
But before there was a balance, there was a crossroad.
In some places the light shone forever,
and all blocks were retained.
In other places there was a balance,
and the light shone only as long as needed.
A desire to unify arose.
Alas, it could not be.
It was a bright and sunny day
When a merge failed [3].
And all blocks were retained. Twice.
Once [here][4] and once [there][5].
For many years we could not see.
Until a dark and rainy night,
when an awareness arose.
And the desire to unify the balance could finally be fulfilled.
[1]: 6efca92acb
[2]: a22f877539
[3]: befa0477cf
[4]: 5158a3c001/src/ObjCRuntime/Runtime.cs (L858)
[5]: 5158a3c001/runtime/runtime.m (L2091)
* [tests] Fix test builds.
* [monotouch-test] RegistrarTest.BlockCollection: allocate more and wait longer for the GC.
Allocate more objects and wait longer for the GC to run.
Hopefully fixes this problem:
[FAIL] RegistrarTest.BlockCollection : freed blocks
Expected: greater than 0
But was: 0
The blocks are freed if we just wait long enough... The problem is that we
don't want to wait very long (makes the tests slow to run), so try to speed
things up by allocating more.
This fixes the following test failures when building for debug with all optimizations enabled:
DispatchTests
[FAIL] DispatchTests.EverAfter : thread check hit
Expected: same as <UIKit.UIKitThreadAccessException>
But was: <System.ArgumentNullException>
at MonoTouchFixtures.CoreFoundation.DispatchTests.EverAfter () [0x000e1] in /Users/xamarinqa/vsts/_work/52/s/tests/monotouch-test/CoreFoundation/DispatchTests.cs:259
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
[FAIL] DispatchTests.MainQueueDispatch : thread check hit
Expected: same as <UIKit.UIKitThreadAccessException>
But was: <System.ArgumentNullException>
at MonoTouchFixtures.CoreFoundation.DispatchTests.MainQueueDispatch () [0x000d1] in /Users/xamarinqa/vsts/_work/52/s/tests/monotouch-test/CoreFoundation/DispatchTests.cs:111
at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
* [monotouch-test] Stop MidiThruConnectionTests.FindTest from randomly failing (#3696)
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.
* [monotouch-test] Enhance MidiThruConnectionTests.FindTest from #3696 comments (#3700)
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.
Which is a bit harder when the issues happens on the macOS.
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.
* [security] Modifying structure of bindings
Added strong dictionary for key generation according to
https://developer.apple.com/documentation/security/certificate_key_and_trust_services/keys/key_generation_attributes
in preparation making a strongly typed key generation possible.
* Making strong dictionary and composite of other strong dictionaries.
* Implementing access control as property type of SecPublicPrivateKeyAttrs.
* Adding new overload for SecKey.CreateRandomKey.
* Moving TokenID to strongly typed property.
* Fix coding style + use nameof
* Fixing Xcode version assertion of key generation tests.
* Fixing errors in test case.
* Fixing whitespace issue.
* Resolving inheritance issue
Removing inheritance between SecKeyGenerationParameters and
SecPublicPrivateKeyAttrs and instead add the necessary properties
to SecKeyGenerationParameters. Adds redundant code, but I don't
see a way around it.
* Moving test case to appropriate test class.
* Creating necessary strong dictionaries for key generation.
* [formatting] Mono coding guidelines
Make sure you're following http://www.mono-project.com/community/contributing/coding-guidelines/
In VSMac: Preferences > Source Code > Code Formatting > C# source code > Policy Mono.
* Remove [Advice] that are specific to GenerateKeyPair
`SecKeyGenerationParameters` and `SecKeyParameters` cannot be used for `GenerateKeyPair`.
* Clarify 'ArgumentException' for invalid 'SecKeyType'
* Fixed CreateRandomKeyTest
- Renamed CreateRandomKeyWithParametersTests to CreateRandomKeyTest.
- Add messages to all asserts.
```
keyGenerationParameters = new SecKeyGenerationParameters ();
keyGenerationParameters.KeyType = SecKeyType.Invalid;
Assert.Throws<ArgumentException> (() => { SecKey.CreateRandomKey (keyGenerationParameters, out _); }, "CreateRandomKey - invalid key type");
```
- ^ didn't work because `SecKeyGenerationParameters`'s setter protects against invalid. There's no constant for invalid so null is returned.
```
Assert.That (SecKey.CreateRandomKey (keyGenerationParameters, out _), Is.EqualTo (SecStatusCode.Param), "CreateRandomKey - Param issue, invalid RSA key size");
```
- ^ `SecKey.CreateRandomKey` doesn't return a `SecStatusCode` like `GenerateKeyPair`.
* Fixes based on spouliot's input.
* Mono styling fix.
* [security] Modifying structure of bindings
Added strong dictionary for key generation according to
https://developer.apple.com/documentation/security/certificate_key_and_trust_services/keys/key_generation_attributes
in preparation making a strongly typed key generation possible.
* Making strong dictionary and composite of other strong dictionaries.
* Implementing access control as property type of SecPublicPrivateKeyAttrs.
* Adding new overload for SecKey.CreateRandomKey.
* Moving TokenID to strongly typed property.
* Fix coding style + use nameof
* Fixing Xcode version assertion of key generation tests.
* Fixing errors in test case.
* Fixing whitespace issue.
* Resolving inheritance issue
Removing inheritance between SecKeyGenerationParameters and
SecPublicPrivateKeyAttrs and instead add the necessary properties
to SecKeyGenerationParameters. Adds redundant code, but I don't
see a way around it.
* Moving test case to appropriate test class.
* Creating necessary strong dictionaries for key generation.
* [formatting] Mono coding guidelines
Make sure you're following http://www.mono-project.com/community/contributing/coding-guidelines/
In VSMac: Preferences > Source Code > Code Formatting > C# source code > Policy Mono.
* Remove [Advice] that are specific to GenerateKeyPair
`SecKeyGenerationParameters` and `SecKeyParameters` cannot be used for `GenerateKeyPair`.
* Clarify 'ArgumentException' for invalid 'SecKeyType'
* Fixed CreateRandomKeyTest
- Renamed CreateRandomKeyWithParametersTests to CreateRandomKeyTest.
- Add messages to all asserts.
```
keyGenerationParameters = new SecKeyGenerationParameters ();
keyGenerationParameters.KeyType = SecKeyType.Invalid;
Assert.Throws<ArgumentException> (() => { SecKey.CreateRandomKey (keyGenerationParameters, out _); }, "CreateRandomKey - invalid key type");
```
- ^ didn't work because `SecKeyGenerationParameters`'s setter protects against invalid. There's no constant for invalid so null is returned.
```
Assert.That (SecKey.CreateRandomKey (keyGenerationParameters, out _), Is.EqualTo (SecStatusCode.Param), "CreateRandomKey - Param issue, invalid RSA key size");
```
- ^ `SecKey.CreateRandomKey` doesn't return a `SecStatusCode` like `GenerateKeyPair`.
* Fixes based on spouliot's input.
* Mono styling fix.
Implement support for optimizing away the dynamic registrar.
* Add a new property (Runtime.DynamicRegistrationSupported) that indicates at
runtime whether dynamic registration is available.
* Check this new property whenever we need dynamic registration.
* Add an optimization to mtouch/mmp that detects whether dynamic registration
is required, and if not, changes Runtime.DynamicRegistrationSupported to
return false.
* Add an optimization to mtouch/mmp that inlines
Runtime.DynamicRegistrationSupported as a constant value.
The end result is that the linker will link away the dynamic registrar if
mtouch/mmp detects that it's not needed.
Benchmark
---------
I've compared the size of entire apps built for device:
|test | Before | After | Diff | % |
|:-----------------------------|-------:|-------:|-------:|------:|
|[monotouch-test/Release][1] | 95.7mb | 95.0mb | -680kb | -0.7% |
|[link sdk/Release][2] | 21.2mb | 20.9mb | -245kb | -1.2% |
|[minimalistic app/Release][3] | 4.58mb | 4.32mb | -259kb | -5.7% |
[1]: https://gist.github.com/rolfbjarne/3871e36d2de8db1a8eee1d9f9276d3d2#monotouch-test-release-wall-optimizations-enabled
[2]: https://gist.github.com/rolfbjarne/3871e36d2de8db1a8eee1d9f9276d3d2#link-sdk
[3]: https://gist.github.com/rolfbjarne/3871e36d2de8db1a8eee1d9f9276d3d2#minimalistic-app
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
Create a table of interface -> protocol in the static registrar, since we need
to be able to look up a protocol given a managed type without looking at the
(possibly linked away) [Protocol] attribute.
* [tests] Build the native test library for macOS and create a binding project for it.
Also add the new binding project to the xammac and link all XM test projects,
which allows us to stop excluding tests that require the native library and
the corresponding bindings.
* [tests] Include more tests in xammac_tests.
* [tests] Correctly ignore the ObjC exception tests in release mode.
- Obsolete `ARFaceAnchor`'s default constructor because it's marked as unavailable.
- Obsolete `CreateFaceGeometry` in `ARSCNFaceGeometry` in favor of `Create` (same as `ARSCNPlaneGeometry`).
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.
Fixesxamarin/xamarin-macios#3166
Apple broke `addAnimation:forKey:` API by changing `CAAnimation` parameter into a
`ISCNAnimationProtocol` that was introduced in Xcode 9 (iOS 11 and company).
We can't break the existing API but we can add an extension method that
reuses the `CAAnimation` overload but takes a `SCNAnimation` and we
turn the `SCNAnimation` into a `CAAnimation` behind the scenes.
For XAMCORE_4_0 we corrected the protocol signature to take `ISCNAnimationProtocol` so there won't be a need for the extension method anymore.
Largely related to somewhat recent frameworks/API additions to XM
ExternalAccessory was added to macOS 10.13 (Xcode9) and can't be run before that (including on the jenkins sierra bots). Also enable that test on tvOS (which added support in Xcode8)
Sadly this creates a breaking change since the `ScaleTransform`
property was re-introduced with an incorrect signature in the new
base class `MPSImageScale`
Unless someone has an idea how to avoid it (I don't see an option)
then we'll have to document it in the 15.7 release notes.
Also add missing _SetScaleTransform call and related unit tests
The original test was to cover both X509Certificate and X509Certiicate2
when using with SecTrust. However the code diverged over time. That and
the different certificates used caused the `*2` tests to hit a time
loop (designed to reduce incorrect errors randomly reported).
We want to keep the "delay" logic for it's intended purpose - but it
should not be needed normally.
The tests have been refactored to reuse the same logic (between both
types of certificates) which solve this (when used with the same
certificates)
Replace https://github.com/xamarin/xamarin-macios/pull/3068
* [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.
Since tvOS 11 there's not a single font, on that platform, that
has the ligatures that the test verified.
Test remains enabled for other platforms.
reference:
https://bugzilla.xamarin.com/show_bug.cgi?id=58929
* [tests] Fix introspection tests for macOS
It seems that apple forgot to ship SSLSetALPNProtocols and SSLCopyALPNProtocols in macOS
there are already radars filled about this https://bugs.swift.org/browse/SR-6131
So this test will fail once Apple fixes this issue. when this happens we need to do two things, reenable
the API and reenable the [Get|Set]AlpnProtocols tests, the one insides 'StreamDefaults' for the mac.
* Implement feedback
* [MetalPerformanceShaders] Activate bindings for Xamarin.Mac and add n… (#2816)
* [MetalPerformaceShaders] Several MPSCnnKernel properties should be readonly (#2938)
The subclasses versions of the properties need Override, cannot be removed since it would break visibility for iOS 10
* Remove some [Model] attributes that sholdn't be needed
* Fix introspection test crashes
* More introspection fixes
* NN does not need to be PascalCased
Remove unneeded Models and BaseTypes
* PR Whitespace fixes and renamings
* Paste fail
* More fixes from PR comments
* [MPS] Adds new intro test, fixes ctors and xtro output
* Removes duplicated availability attributes.
* Removes obsoleted API from macOS since mps is new to it.
* Fixes xtro output.
* Adds missing API.
* Fixes parameterless ctors, some of them do not really work, found
by our new intro test and disabled the one that seem to not make
sense due to the presence of DesignatedInitializers.
* Fixes a selector typo.
* Adds new `ShouldNotExposeDefaultCtorTest` to intro.
ShouldNotExposeDefaultCtorTest
==============================
This test checks for types with a parameterless ctor that are subclasses
of `NSObject` and then cheks if the BaseType of said objects also expose
a parameterless ctor (all in .NET land), if this is not the case it reports
them and so they can manually audited. Also this test has the ability to
print alloc/init ObjC code by setting `genObjCTestCode` to `true` so you can
take this code into an Xcode project and easily tests the ctors.
It seems that xtro (sharpie) does not have a complete picture of when a ctor
must be exposed hence the hability to generate this code and manually test.
Right now this test is just enabled for MPS since it is the scope of this PR.
In the future it should be enabled for all other frameworks and the output be
manually audited.
* [MPS] Fixes premature collection possible in bindings (bug 59547) and implements feedback.
https://bugzilla.xamarin.com/show_bug.cgi?id=59547
* Fixes premature collection possible in bindings im MPSKernel.cs
* Fixes MPSImageHistogramTest from using deprecated API.
* Removes renamed selectors and typos from ApiSelectorTest and ApiTypoTest.
* [MPS] Reenable Copy API and DesignatedInitializer xtro feedback
* Implement more feedback
* More feedback
However there's a small window between the time we get a pointer
and the call to the native selector where the memory is not fixed.
During this time the GC can move the memory resulting in hard to
diagnose crashes.
Note: `initWithValues:count:` copies the provided memory so what
happens afterward is not an issue.
- Fixes bug #57350: Review new CoreImage filters added in Xcode 9
(https://bugzilla.xamarin.com/show_bug.cgi?id=57350).
- Adds `AVCameraCalibrationData` and `CIBarcodeDescriptor` to `generator-filters`.
- Fixes `ApiCoreImageFiltersTest`'s `GenerateBinding` to use valid `[CoreImageFilterProperty]`.
- In `CheckManagedFilters` generate code of SuperClass when detected so it's easier to bind.
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.
- Fixes bug #59928: SKCloudServiceSetupViewController.LoadAsync() does not work correctly when passed an SKCloudServiceSetupOptions object instead of a manually-created NSDictionary
(https://bugzilla.xamarin.com/show_bug.cgi?id=59928)
For some reason this happens with the watchOS 4.2 simulator on our
Jenkins bots (but not locally for me).
The test is updated to ignore errors as depending on the sim default
content does not seems possible.
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.
monotouch-test has a wildcard to automatically include new test files, but
this should not include generated files, because:
* The generated files are generated when needed, which means we can't rely on
the wildcard to trigger their generation, because the wildcard won't find
them before they exist, and as such msbuild won't detect that they're
needed.
* This means the generated files must be listed separately, but in that case
they shouldn't be found by the wildcard too, because that leads to:
/Library/Frameworks/Mono.framework/Versions/5.4.0/lib/mono/msbuild/15.0/bin/Roslyn/Microsoft.CSharp.Core.targets(84,5): error MSB3105: The item "ObjCRuntime/TrampolineTest.generated.cs" was specified more than once in the "Sources" parameter. Duplicate items are not supported by the "Sources" parameter.
So move the generated files to a different directory, so that the wildcard
doesn't find them.
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.
This test fails on the bots:
[FAIL] MDLVoxelArrayTest.BoundingBoxTest : MaxX (M)
Expected: -1.0f
But was: 0.0f
For some unknown reason I'm not able to reproduce locally, but the actual
values look normal, so update the test to accept those as well.
* The original API was incorrect. Lack of documentation at binding time?
* Use a strong dictionary to expose the credentials
The fixed version cannot be unit tested since it popups an UI.
The test case attached to the bug report [1] can be used to verify it.
reference:
[1] https://bugzilla.xamarin.com/show_bug.cgi?id=60423
* [monotouch-test][GameplayKit] GKAgent3D isn't available on iOS 9.
Fixes this test failure:
> [FAIL] GKAgent3DTest.RotationTest : ObjCRuntime.RuntimeException : Wrapper type 'GameplayKit.GKAgent3D' is missing its native ObjectiveC class 'GKAgent3D'.
* [monotouch-test][MPS] MPSImageHistogram.HistogramSizeForSourceFormat doesn't seem to work on iOS 9.
Calling MPSImageHistogram.HistogramSizeForSourceFormat seems to abort on iOS 9
due to invalid arguments no matter which pixel format I use:
> /BuildRoot/Library/Caches/com.apple.xbs/Sources/MetalImage/MetalImage-39.3/MetalImage/Filters/MIHistogram.mm:103: failed assertion `[MPSImageHistogram histogramSizeForSourceFormat:] unsupported texture format: 114'
So only call this method on iOS 10+.