Hoping that one day we'll have a System.Numerics.Matrix3x3 type we can replace our
RMatrix3 type with:
* Add all API in OpenTK.Matrix3 that also exists in equivalent form in System.Numerics.Matrix4x4.
* Remove all API that doesn't exist in equivalent form in System.Numerics.Matrix4x4.
For NMatrix2 and NMatrix3:
* Change the fields to be M## instead of R#C# (this is how System.Numerics does
it, and also how we do it in other matrix types).
* Add obsolete and hidden R#C# versions of the fields to ease migrating existing
code to .NET (but let's try to remove these in xamcore 5).
* Add properties in legacy Xamarin recommending users to use the new naming.
* A few other API additions to add equivalent API to the matrix types in System.Numerics.
For CGAffineMatrix:
* Add obsolete and hidden versions of the legacy field names to .NET to ease
migrating existing (but let's try to remove these in xamcore 5).
Fixes https://github.com/xamarin/xamarin-macios/issues/14125.
* Remove ObjCRuntime.nfloat (in favor of System.Runtime.InteropServices.NFloat).
* Automatically add a reference to the System.Runtime.InteropServices.Internal
package, so that developers get the new NFloat API (with operators) we've
added post .NET 6 (but don't do this for .NET 7).
* Automatically add a global using alias for
System.Runtime.InteropServices.NFloat -> nfloat. This is not behind the
usual `ImplicitUsings` condition our other implicit usings are, because
they're off by default for existing projects, and the main target for the
global using alias for nfloat is upgraded projects.
* Automatically generate a global using alias (like above) in the generator
for all code the generator compiles.
* Update xtro entries to reference System.Runtime.InteropServices.NFloat
instead of ObjCRuntime.nfloat.
* Add a workaround for a hopefully temporary issue with .NET/CoreCLR where the
wrong runtime pack is selected otherwise (without the new NFloat API, so
nothing works at runtime).
Ref: https://github.com/xamarin/xamarin-macios/issues/13087
* Using `NativeHandle` avoids implicit casts [1]
* Do not expose `IntPtr` as the type for the `SuperClass` handle
[1] likely not an issue with JIT/AOT optimization, less sure for the
interpreter. No harm in not having those in the product assembly.
There's no corresponding System.Runtime.InteropServices.NFloat.CopyArray method in .NET.
It turned out that the API where we used CopyArray don't need to use CopyArray at all, the same can be accomplished faster and simpler by using unsafe code.
As a part of the breaking changes in .NET, we introduced a new type,
`ObjCRuntime.NativeHandle`, to represent native handles.
This meant that constructors taking taking `IntPtr handle`:
```cs
public class MyUIViewController : UIViewController {
protected MyUIViewController (IntPtr handle)
: base (handle)
{
}
}
```
would have to be ported to take `NativeHandle handle`:
```cs
public class MyUIViewController : UIViewController {
protected MyUIViewController (NativeHandle handle)
: base (handle)
{
}
}
```
The unfortunate part is that there will be no compiler warnings or errors
flagging this, so users won't know to do it unless they either read the
documentation (🤣) or run into the problem, googles for a while, runs into
someone else who had the same problem, and applies their (probably broken)
fix.
So we change our logic to:
1. Look for and use an `(IntPtr)` (or `(IntPtr, bool)`) constructor in .NET if
the `NativeHandle` version isn't found.
2. Show a warning.
3. Some time in the future maybe remove this hack/workaround.
Fixes https://github.com/xamarin/xamarin-macios/issues/14046.
fixes#13160
- remove unused types
- use System.Numerics when possible
- move own created types from OpenTK namespace to CoreGraphics
- create missing types in CoreGraphics namespace
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Fixes race condition where finalized objects are resurrected by the finalizer and for a brief moment `Runtime.TryGetNSObject`/`Runtime.GetNSObject` would return them even though a new instance is supposed to be used. In multi-threaded scenarios this would result in reused objects (same native handle) to suddenly become invalid when the UI thread processes the delayed finalization.
Fixes#13921
When exception marshalling was originally implemented, for backwards
compatibility concerns it was only turned on by default for platforms that
really needed it (watchOS).
However, exception marshalling is by far the safest option, so in .NET we're
enabling it by default for all platforms (it's still possible to disable it
for those who wants to).
Ref: https://docs.microsoft.com/en-us/xamarin/ios/platform/exception-marshaling
This makes diagnosing what happens much easier in some cases.
Exhibit A, pre fix:
*** Terminating app due to uncaught exception 'ObjCRuntime.RuntimeException', reason: 'Failed to lookup the required marshalling information.
Additional information:
Selector: conformsToProtocol:
Type: ViewController
Exhibit B, post fix:
*** Terminating app due to uncaught exception 'ObjCRuntime.RuntimeException', reason: 'Failed to lookup the required marshalling information.
Additional information:
Selector: conformsToProtocol:
Type: ViewController
(ObjCRuntime.RuntimeException)
Failed to get the 'this' instance in a method call to templ.ViewController.InvokeConformsToProtocol. (ObjCRuntime.RuntimeException)
at Registrar.DynamicRegistrar.GetMethodDescriptionAndObject(Type type, IntPtr selector, Boolean is_static, IntPtr obj, IntPtr& mthis, IntPtr desc)
at ObjCRuntime.Runtime.GetMethodAndObjectForSelector(IntPtr klass, IntPtr sel, Boolean is_static, IntPtr obj, IntPtr& mthis, IntPtr desc)
at ObjCRuntime.Runtime.get_method_and_object_for_selector(IntPtr cls, IntPtr sel, Boolean is_static, IntPtr obj, IntPtr& mthis, IntPtr desc, IntPtr& exception_gchandle)
Failed to marshal the Objective-C object 0x7f813fd2f470 (type: ViewController). Could not find an existing managed instance for this object, nor was it possible to create a new managed instance (because the type 'templ.ViewController' does not have a constructor that takes one NativeHandle argument). (ObjCRuntime.RuntimeException)
at ObjCRuntime.Runtime.MissingCtor(IntPtr ptr, IntPtr klass, Type type, MissingCtorResolution resolution)
at ObjCRuntime.Runtime.ConstructNSObject[T](IntPtr ptr, Type type, MissingCtorResolution missingCtorResolution)
at ObjCRuntime.Runtime.ConstructNSObject(IntPtr ptr, IntPtr klass, MissingCtorResolution missingCtorResolution)
at ObjCRuntime.Runtime.GetNSObject(IntPtr ptr, MissingCtorResolution missingCtorResolution, Boolean evenInFinalizerQueue)
at Registrar.DynamicRegistrar.GetMethodDescriptionAndObject(Type type, IntPtr selector, Boolean is_static, IntPtr obj, IntPtr& mthis, IntPtr desc)
* A lot of obsolete/deprecated removal.
* Remove the NSDraggingInfo model, which required numerous other changes.
* Remove the NSPasteboardReading/NSPasteboardWriting models, which required more
numerous changes.
* Update the tests accordingly.
* Use 'ObjCException' instead of 'MonoTouchException' as the managed exception
type wrapping an NSException for all platforms in .NET (that was already the
case for macOS, so no change there).
* Make the ObjCException class behave like the MonoTouchException class does.
* Move the ObjCException type to the ObjCRuntime namespace in .NET.
Fixes https://github.com/xamarin/xamarin-macios/issues/13855.
Co-authored-by: TJ Lambert <50846373+tj-devel709@users.noreply.github.com>
This turned out a bit complex, because numerous ModelIO APIs were initially bound
with wrong matrix types, and had to be rebound later (our matrix type was transposed
with regards to the native matrix type). The new versions often had to use worse
names, so that's being fixed now. This means that numerous tests had to be updated,
because the original API now returns non-transposed matrices.
* Mostly just removal of obsolete/deprecated API.
* Modified CAScrollLayer.ScrollMode to use the good name
(CAScrollLayer.ScrollMode) for the strongly typed enum, and then have a
WeakScrollMode property for the NSString version (like we do elsewhere).
* Use `is` instead of `==` for null checks
* Use `ThrowHelper` to throw common exceptions
* Use faster `CFString` API (over the slower `NSString` variants)
* [tests] Adjust UTTypeTest.cs to build for net profile
* Use the native `NSStringFrom*` API so we can, eventually, use the
native code to parse them from `NSString` and also ensure increased
compatibility with any code that expects the native string representation
* Add unit tests for `ToString` methods
Also use [`System.HashCode`](https://docs.microsoft.com/en-us/dotnet/api/system.hashcode?view=net-6.0) to generate the hash code
* Improve the API for both legacy Xamarin and .NET.
* Obsolete the old API in legacy Xamarin and point to the new API.
* Remove the old API in .NET.
* Add nullability.
This means removing numerous obsolete/deprecated methods where better/more
correct alternatives already exist.
Also fix one obsolete message and adjust the tests.
These types come from the CFNetwork.framework, but for some reason they were bound inside CoreServices many years ago.
This resolves a potential issue where we might end up linking with the
CoreServices framework instead of CFNetwork framework (because we use the
namespace of types to determine which framework they belong to).
This makes it easier to figure out problems in consuming code, since it makes
it easier to identify where things start to go wrong.
Fixes https://github.com/xamarin/maccore/issues/2539.
Rename the public fields in CGAffineTransform to:
* Follow our naming convention (public API should always start with an
upper-case letter).
* Use the same names as Apple's version to ease porting Swift/Objective-C
code.
Fixes https://github.com/xamarin/xamarin-macios/issues/13494.
* Remove obsolete API from .NET.
* Change API marked with XAMCORE_4_0 due to naming problems to be in .NET.
* Change API marked with XAMCORE_4_0 due to using non-generic NSDictionary to be
in XAMCORE_5_0 instead (yay!). This is because of #13704, which can make using
generic NSDictionary in API buggy, and I feel it's a bit too risky to change this
for .NET with the time we have available (no time to fix#13704). Additionally,
moving this to XAMCORE_5_0 makes it possible to keep grepping for XAMCORE_4_0 to
see what's left. Update all the CoreData API to be better as defined by our XAMCORE_4_0
define. Mostly using generic NSSet/NSDictionary types instead of the non-generic
ones, and other misc naming improvements.
* Change API marked with XAMCORE_4_0 due to both of the above to do both of the
above - add a version of the naming issue fixed for .NET + a version with the generic
dictionary for XAMCORE_5_0.
* Implement a column-major version of SCNMatrix4 in .NET to match native code.
* This was done by copying the existing SCMatrix4 implementation, and modify it
as required (doing it with conditional compilation in the same file turned out
to be quite messy, so I opted for using different files for legacy Xamarin and
.NET).
* There was one major change: the matrix inversion algorithm is new (copied from
.NET instead), because the legacy Xamarin version showed strange results with
some test values.
* Add setters for SCNMatrix4.Column[0-3] for legacy Xamarin to match the .NET API.
* Add CreateFromColumns methods for legacy Xamarin to match the .NET API.
* Add tests for all the new API.
Fixes https://github.com/xamarin/xamarin-macios/issues/4652.
It's our own enum, and all the API using it have been obsoleted/removed.
There doesn't seem to be any other usage of it on GitHub either (only our own
source code and documentation).
* Fix `CGColorConversionInfoTriple` name (missing initial `C`)
* Rename `RectangleFExtensions` to `CGRectExtensions` since the former
name has not been around for a while
* Remove API naming mistakes (already under XAMCORE_4_0)
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
Public fields shouldn't start with a lower-cased letter.
Also provide public properties in legacy Xamarin so that we can write
identical code for both, and obsolete the lower-cased fields.
AudioUnit needs a GCHandle in the input callback, which means we have to create it
when SetInputCallback is called (like we already do for SetRenderCallback).
Fixes https://github.com/xamarin/xamarin-macios/issues/13637.
* [ObjCRuntime] Fix the DisposableObject.Owns property to return the correct value. Fixes#13646.
Ops...
Also add tests to avoid more oopses.
Fixes https://github.com/xamarin/xamarin-macios/issues/13646.
* Update tests/monotouch-test/AudioToolbox/AudioConverterTest.cs
Co-authored-by: TJ Lambert <50846373+tj-devel709@users.noreply.github.com>
* [Xcode13.2] Bump to Xcode 13.2 RC (#13497)
* [Xcode13.2] Bump to Xcode 13.2 Beta 2
Breaking changes addressed for legacy
* HomeKit
* CallKit
* CoreLocation
* [xcode13.2] Bump to Xcode 13.2 RC and apply feedback
* [AppKit] Fix missing Notifications
* Fix xtro
* [xcode13.2] Bump versions and use stable Xcode 13.2
* [monotouch-tests] Make TestAddingByComponents work on the last day of the year
Happy New Year!!
* NO BOM PLZ!
Once upon a long time ago we decided to mark the properties in the
UITextInputTraits protocol as required in our API definition, because that way
we'd inline these properties in any class that implemented the
UITextInputTraits protocol, which made calling these properties much easier.
At a later point, we implemented better support for protocols, and now we
automatically generate extension methods for such properties (a corresponding
Get/Set method for the get/set property accessors), so we don't need these
inlined properties anymore.
However, removing them would be a breaking change, so we were stuck with these
redundant inlined properties, until .NET came along.
Ref: 0e80570863
Fixes https://github.com/xamarin/xamarin-macios/issues/5831.
Once upon a time there was a single VTCompressionSession.Create method, which
was [driving users insane][1] - they had to manually call CFRetain to avoid
crashes! What an abomination!!
Insane users are clearly not happy users, and we wanted happy users, so time
and effort went into creating a solution: a new Create overload was devised
and [implemented][1], taking extreme care to not break our brave and insane
existing users who had to manually call CFRetain. Because the fix would break
existing users - the now extraneous CFRetain would mean that their apps would
leak memory. *A lot* of it! That's bad, so we decided to make sure that didn't
happen.
Of course, dear old Murhpy wanted a say, so the new Create overload didn't do
as intended. In fact, it had the same insane behavior the old Create overload
had! Ops.
But Murphy decided to have even more fun: the changes were so buggy, that they
in fact fixed the old Create overload! Which from now on wouldn't require the
horrendous manual CFRetain calls... and effectively introducing the leak the
fix was trying so hard to not introduce.
Oh dear Murphy.
Of course he had another trick up his sleeve: in our extreme efforts to help
our users, we added an Obsolete attribute that would tell people to use the
new Create overload.
Let that sink in for a moment: we had an Obsolete attribute on a function that
was (now) perfectly fine, telling users to use a function that was broken.
To get the correct behavior, users would now have to to remove their manual
CFRetain calls, and ignore the obsolete warning on the old (and correct)
Create overload which told users to use the new (and buggy) Create overload.
In other words: still insanity, just a slightly different flavor.
Murphy had a field day!
Time went by, and eventually a sane enough user [reported the insanity to
us][2]. Even better: the user actually provided a fix! Truly, we have some
amazing users.
Unfortunately, the user didn't have access to our code history, and thus was
obviously not able to see the whole picture, and the fix ended up being
incorrect.
Unrelated lesson learned: don't forget your history, otherwise you'll end up
repeating mistakes from the past.
So now came the problem: how to fix all the APIs? In a way that didn't make
our users' existing apps just suddenly start crashing or leaking?
There really was no way, so nothing really happened for quite a while.
Then, an opportunity presented itself: we'd be able to do [widespread breaking
changes][3].
So, hoping that Murphy stays away this sunny winter day, I'm changing both the
new and the old Create overloads to do the right thing. But only in .NET,
where we can do breaking changes! Or at least that's my intention. I've tried
to stave off our dear old friend by adding his arch enemy: unit tests. Which,
of course, Murphy couldn't stay away from, but it seems adding a few
Thread.Sleep calls makes him bored enough to stay away. Hopefully for good...
[1]: 66c50b9a17
[2]: https://github.com/xamarin/xamarin-macios/pull/2070
[3]: https://github.com/xamarin/xamarin-macios/issues/13087
This fixes a problem where we'd build the same project reference from
dotnet-shared.csproj in parallel, and each build would stomp on eachother
(because we'll now clone the project references in dotnet-shared.csproj).
This als required updating project files to use MSBuildThisFileDirectory
instead of MSBuildProjectDirectory, which makes it easier for xharness to
inline/process these files, because MSBuildThisFileDirectory is easy to know
when processing a file, while MSBuildProjectDirectory depends on the calling
project, which complicates matters significantly.
A fix in MonoTouch.Dialog was also required.
New commits in migueldeicaza/MonoTouch.Dialog:
* migueldeicaza/MonoTouch.Dialog@59fbf5b [dotnet] Shared project files don't need the DefaultTargets/ToolsVersion/xmlns attributes.
Diff: 4d0e0a9a5f..59fbf5bb1b
Fixes https://github.com/xamarin/maccore/issues/2527.
Remove Runtime.Arch and ObjCRuntime.Arch from Mac Catalyst, because they don't
apply for a Mac Catalyst app (which is neither a simulator environment, nor a
device environment).
This means that code using these APIs will have to be re-evaluated to
determine what's the correct behavior for Mac Catalyst.
Also update our tests accordingly.
Fixes https://github.com/xamarin/xamarin-macios/issues/10312.
* Change all XAMCORE_4_0 conditions to NET conditions.
* Add numerous Release attributes that xtro started complaining about.
* Misc other minor API changes/updates.
* [ObjCRuntime] Remove deprecated availability attribute API from .NET.
They're quite useful for binding code though, so instead of removing them completely,
make them binding-only attributes (like numerous other binding attributes we have)
for .NET.
* [src] Remove removed attributes from the list of attributes that should be removed by the linker.
* [tests] Update tests to not use the old attributes for .NET.
* [monotouch-test] Ignore a few tests in non-ARM64 simulators.
Some tests fail when running on an M1, but in a x64_86 mode, so just ignore
those unless we're running on ARM64 (this will currently exclude them on
x86_64 hardware too, but that'll eventually not be a problem anymore when
there's no more x86_64 hardware, and just checking for ARM64 is easier than
checking for x86_64 mode on an ARM64 CPU).
* Make more legacy projects unsafe.
* [Foundation] Make numerous CFArray and NSArray APIs take/return NativeHandle instead of IntPtr.
* [src] Fix a lot of other cases of IntPtr -> NativeHandle.
This is just fallout from the CFArray/NSArray in the previous commit.
Add a new struct, ObjCRuntime.NativeHandle, which will be used to represent
native handles for .NET (instead of using IntPtr). The main purpose is to be
able to use 'nint' as a number in API while not being prevented from using
native handles as well.
One example is NSMutableString, which has a constructor that takes a single
'nint capacity' parameter. With this change, we'll also be able to have a
constructor that takes a native handle in .NET - otherwise we'd have two
constructors with the same signature, because a C# 'nint' is just an 'IntPtr'.
This change required numerous changes pretty much everywhere. The work is
split up in commits as well as I was able to, and each commit explains what it
does.
Fixes https://github.com/xamarin/xamarin-macios/issues/13126.
* Make the .NET project files for BundleResources and EmbeddedResources follow
the pattern of all the other test projects.
* Move the LangVersion and AllowUnsafeBlocks propertieso to the shared project
file.
* [src] Remove the Xamarin.iOS.dll reference assembly for Mac Catalyst.
Xamarin.iOS.dll won't be compatible with Mac Catalyst in .NET 6 (because there
won't be any backwards compatibility), so we don't need the assembly that has
type forwarders to Xamarin.MacCatalyst.dll.
* Bump MonoTouch.Dialog
New commits in migueldeicaza/MonoTouch.Dialog:
* migueldeicaza/MonoTouch.Dialog@4d0e0a9 Remove usages of UIWebView when compiling for Mac Catalyst.
Diff: 5a05c6912e..4d0e0a9a5f
* [tests] There's no NSFileProviderPage in Mac Catalyst.
* [tests] Fix CBUUID link sdk test to work correctly on Mac Catalyst.
* There should be no public (IntPtr) constructor, at most there should be a
protected one for NSObject subclasses. There should be no such constructors
for classes that just implement INativeObject.
* There should be no public (IntPtr, bool) constructor at all, they should all
be internal.
* If changing the visibility or removing the ctor is a breaking change, then
make it happen for .NET only.
Otherwise we'll create a CGImage with a zero Handle, which is usually not the
right thing to do. Still, keep the old behavior for legacy Xamarin for the
sake of backwards compat.
Fixes:
MonoTouchFixtures.UIKit.FontTest
CoreText note: Client requested name ".SFNS-Regular", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
CoreText note: Set a breakpoint on CTFontLogSystemFontNameRequest to debug.
[FAIL] NullFonts : WithSize
Expected: not null
But was: null
at MonoTouchFixtures.UIKit.FontTest.NullFonts() in /Users/builder/azdo/_work/1/s/xamarin-macios/tests/monotouch-test/UIKit/FontTest.cs:line 165
* [tools] Extract the logic to parse OSPlatformAttribute platform names to a separate file/class.
* [introspection] Migrate .NET code to use the new .NET-style availability attributes.
This also means using the 'ApplePlatform' enum instead of the 'PlatformName'
enum, because the latter will be removed in .NET.
* [FileProvider] Exclude some deprecated API from .NET.
* [AVFoundation] Adjust availability attribute for AVCaptureStillImageOutput.HighResolutionStillImageOutputEnabled.
* Update tests.
The FSEventStreamCreate method takes a pointer to a structure with context information,
which contains a user-defined pointer value in addition to a few callbacks. Previously
we were passing the GCHandle as a pointer to this structure, which is obviously quite
wrong (as evidenced by a native crash when calling FSEventStreamCreate).
Changes:
* Modify the code to provide the expected context structure instead with the GCHandle
as a field in that structure.
* Add a release callback to the context structure to release the GCHandle.
* This avoids the need for storing the GCHandle as a field in the FSEventStream instance.
* It also avoids also the need for overriding Dispose to release said GCHandle.
* Modify the callback code to use the [UnmanagedCallersOnly] attribute for .NET
(ref: #10470).
This was a regression introduced in 8c99bdc9ad.
Fixes https://github.com/xamarin/xamarin-macios/issues/13325.
The supposed handle for system sounds is an uint, which does not match the
IntPtr handle INativeObject uses, so remove the INativeObject interface from
the SystemSound class.
* Remove the SslCipherSuite enum from .NET, it's complicated to implement
correctly on macOS for both x64 and arm64, and it's also obsolete, so just
remove it.
* Change the type for NSUrlSessionTaskTransactionMetrics.NegotiatedTlsCipherSuite
to be TlsCipherSuite instead of SslCipherSuite for .NET (this is in fact the
correct value according to the headers).
Fixes https://github.com/xamarin/xamarin-macios/issues/11498.
* Change all XAMCORE_4_0 defines to NET defines to get the new API version in
.NET.
* Remove some dead code.
* Change all the old-style [Availability] attributes to new-style [Obsoleted]
or [Deprecated].
* Adjust tests.
Fixes when building with XAMCORE_4_0:
> uikit.cs(6775,3): error CS0246: The type or namespace name 'UITextWritingDirection' could not be found (are you missing a using directive or an assembly reference?)
> uikit.cs(6597,3): error CS0246: The type or namespace name 'UITextWritingDirection' could not be found (are you missing a using directive or an assembly reference?)
> uikit.cs(6601,41): error CS0246: The type or namespace name 'UITextWritingDirection' could not be found (are you missing a using directive or an assembly reference?)
Fixes https://github.com/xamarin/xamarin-macios/issues/6573.
* Make CGPDFObject a common subclass for the CGPDF[Array|Dictionary|Stream]
classes, and keep the object lifetime code there.
* Enable nullability and fix code accordingly.
* Use 'is' and 'is not' instead of '==' and '!=' for object identity.
* Use 'nameof (parameter)' instead of string constants.
* Make any (IntPtr) constructors internal for .NET
* Simplify block creation code a bit.
* [CGImageMetadataTag] Subclass NativeObject + numerous other code updates
* Subclass NativeObject to reuse object lifetime code.
* Enable nullability and fix code accordingly.
* Use 'is' and 'is not' instead of '==' and '!=' for object identity.
* Use the null-safe NativeObjectExtensions.GetHandle extension method to get
the handle instead of checking for null (avoids some code duplication).
* Use 'nameof (parameter)' instead of string constants.
* Use the 'Runtime.GetNSObject<T> (IntPtr, bool)' overload to specify handle
ownership, to avoid having to call NSObject.DangerousReleaes manually later.
* Remove the (IntPtr) constructor for .NET
* Fix nullability attribute.
* [tests] Don't dispose a property value.
It ends up being the object instance we've stored elsewhere, which we don't
expect to be disposed.
* [ObjCRuntime] Add a non-deprecated internal system-version checking API and use it everywhere.
The PlatformHelper class is deprecated, so implement a new version that isn't
deprecated, and which shares a similar API between all platforms - the Check*
methods includes the name of the platform, because that makes it clearer which
version we're talking about from the call site. There's a quirk though:
there's no separate ChecktvOS or CheckMacCatalyst, because the system version
is the same as for iOS, so we can just use 'iOS'.
For macOS we can now use NSProcessInfo.ProcessInfo.OperatingSystemVersion to
determine the OS version, because it's supported in all versions of macOS we
support for .NET.
Fixes issues such as this when building with XAMCORE_4_0:
> CoreMedia/CMSync.cs(590,11): error CS0103: The name 'PlatformHelper' does not exist in the current context
* Bring back PlatformHelper.CheckSystemVersion, but only for !NET.
* [tests] Remove 32-bit macOS logic, it's long dead.
* [introspection] Implement OS version check using 'NSProcessInfo.ProcessInfo.IsOperatingSystemAtLeastVersion' for macOS.
* [monotouch-test] Use TestRuntime.[Check|Assert]XcodeVersion instead of PlatformHelper.CheckSystemVersion.
* Subclass NativeObject to reuse object lifetime code.
* Enable nullability and fix code accordingly.
* Use 'is' and 'is not' instead of '==' and '!=' for object identity.
* Use the null-safe NativeObjectExtensions.GetHandle extension method to get
the handle instead of checking for null (avoids some code duplication).
* Use 'nameof (parameter)' instead of string constants.
* Call 'GetCheckedHandle ()' (which will throw an ObjectDisposedException if
Handle == IntPtr.Zero) instead of manually checking for IntPtr.Zero and
throwing ObjectDisposedException.
* Use the 'Runtime.GetNSObject<T> (IntPtr, bool)' overload to specify handle
ownership, to avoid having to call CFObject.CFRelease manually later.
* Use Array.Empty<T> instead of creating an empty array manually.
* Remove the (IntPtr) constructor for .NET.
Fixes this test failure on macOS 10.14:
MonoTouchFixtures.WebKit.WKPreferencesTest
[FAIL] TextInteractionEnabledTest : Getter
Expected: No Exception to be thrown
But was: <Foundation.ObjCException: NSInvalidArgumentException: -[WKPreferences setTextInteractionEnabled:]: unrecognized selector sent to instance 0x7fa228f12640
at (wrapper managed-to-native) ObjCRuntime.Messaging.void_objc_msgSend_bool(intptr,intptr,bool)
at WebKit.WKPreferences.set__OldTextInteractionEnabled (System.Boolean value) [0x0002c] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/mac/mobile/WebKit/WKPreferences.g.cs:482
at WebKit.WKPreferences.set_TextInteractionEnabled (System.Boolean value) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/WKWebKit/WKPreferences.cs:32
at MonoTouchFixtures.WebKit.WKPreferencesTest+<>c__DisplayClass0_0.<TextInteractionEnabledTest>b__0 () [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/tests/monotouch-test/WebKit/WKPreferencesTest.cs:19
at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in /Library/Frameworks/Xamarin.Mac.framework/Versions/Current/src/Xamarin.Mac/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395
--- End of stack trace from previous location where exception was thrown ---
at NUnit.Framework.Internal.ExceptionHelper.Rethrow (System.Exception exception) [0x00006] in <d392db2fb3d64f4fa564a7b744fc7801>:0
at NUnit.Framework.Internal.Reflect.DynamicInvokeWithTransparentExceptions (System.Delegate delegate) [0x00013] in <d392db2fb3d64f4fa564a7b744fc7801>:0
at NUnit.Framework.Internal.ExceptionHelper.RecordException (System.Delegate parameterlessDelegate, System.String parameterName) [0x00067] in <d392db2fb3d64f4fa564a7b744fc7801>:0 >
* Submodule MonoTouch.Dialog.
Submodule MonoTouch.Dialog, so that we can easily build it using .NET. This
submodule will become redundant when/if we publish a .NET version of
MonoTouch.Dialog, but until that happens we need it at least for our own test
suites.
This also means we have to copy our NuGet.config and global.json files to the
MonoTouch.Dialog project directory so that we point msbuild to use our local
build.
New commits in spouliot/Touch.Unit:
* spouliot/Touch.Unit@cbda703 [Touch.Client] Use MonoTouch.Dialog from a submodule. (#109)
Diff: 3345db2f4e..cbda703583
* Use relative path for submodule.
And fix indentation and set the branch name.
* Don't use 'RootTestsDirectory' when it might not be defined yet.
* [tests] Our test projects don't need to reference MonoTouch.Dialog directly.
The projects get the MonoTouch.Dialog reference indirectly through the
Touch.Client project reference.
* [tests] Only validate unique errors in the .NET unit tests.
* [tests] No need to reference System.Json anymore, that's handled directly in the MonoTouch.Dialog project.
* [tests] Reference nunit.framework.targets so we get a workaround for an NUnit issue everywhere.
* [msbuild] Only try to create a package if we're able to create an app bundle.
This fixes an issue where a library project would try (and fail) to create a
package when 'CreatePackage=true' (which could be set for the executable
project, but inherited by the library project since the executable project
depends on it).
* [tests] Adjust PackTest.BindingXcFrameworksProject to not set the AssemblyName property.
MSBuild ends up being very confused when the project we're trying to build
depends on other projects, because AssemblyName is set for all the projects
being build, and MSBuild complains about ambiguous projects:
> error: Ambiguous project name 'bindings-xcframework-test'
The deadlock goes like this:
1. Thread A holds the framework_peer_release_lock lock, and tries to lock the
refcount_mutex lock.
2. Thread B holds the refcount_mutex, and is waiting for the GC to complete
3. Thread C is trying to lock the framework_peer_release_lock while running
the GC.
The fix is in thread A, by not doing anything at all with the
framework_peer_release_lock lock locked.
The code contains extensive comments explaining the situation and the solution.
Fixes https://github.com/xamarin/xamarin-macios/issues/13066.
Co-authored-by: Chris Hamons <chris.hamons@xamarin.com>
* Subclass NativeObject to reuse object lifetime code.
* Enable nullability and fix code accordingly.
* Use 'is' and 'is not' instead of '==' and '!=' for object identity.
* Use CFString.CreateNative/ReleaseNative instead of other means to create native
strings (the fastest and least memory hungry option).
* Use 'nameof (parameter)' instead of string constants.
* Call 'GetCheckedHandle ()' (which will throw an ObjectDisposedException if
Handle == IntPtr.Zero) instead of manually checking for IntPtr.Zero and throwing
ObjectDisposedException.
* Use CFArray helper methods to create arrays (and implement some helper methods
that didn't exist).
* Add a few tests for the new CFArray helper methods.
This makes it easier to iterate over the platforms we're building for, because
we can use "macOS" to compute the variable names we're interested in (like we
already can for iOS, tvOS, watchOS and MacCatalyst).
* Add an (IntPtr, bool) constructor so that AudioUnit works with Runtime.GetINativeObject.
* Keep track of ownership, so that AudioUnit doesn't free the native resources
when it doesn't own them.
* Update a test to verify that calling 'AVAudioIONode.AudioUnit' multiple
times and disposing the result between them works (this fails if AudioUnit
doesn't keep track of ownership).
I recently deleted the generated makefile support for building and running our
test suites. It turned out that it was used for building the packaged
Xamarin.Mac tests, so it wasn't as unused as I thought.
So fix the building and packaging of Xamarin.Mac tests to not use the
(non-existent) makefile targets, but instead replicate it with manual make
code.
Also take the opportunity to add packaging and execution of the .NET versions
of these test suites we execute on other macOS versions (both for macOS and
the Mac Catalyst).
* [devops] Use stricter matching when finding the Xamarin.Mac pkg link.
Otherwise the branch name in any package could end up matching the pattern we
were looking for:
XM_PACKAGE=https://bosstoragemirror.blob.core.windows.net/wrench/tests-package-xamarin-mac-tests/15759261d425ae08494b0a26862a0b1356c5f8ec/5268864/package/Microsoft.iOS.Bundle.15.0.101-ci.tests-package-xamarin-mac-tests.68.pkg
is just clearly wrong.
* MTLCopyAllDevices returns a retained object, so we need to release it.
* MTLCopyAllDevicesWithObserver returns an observer (no need to provide one). This
means we can obsolete the 'ref NSObject' overload (the API doesn't make sense),
and instead add an 'out NSObject' overload.
* The returned observer from MTLCopyAllDevicesWithObserver is retained, so we must
release it.
* The returned array from MTLCopyAllDevicesWithObserver is a retained object, so
we need to release it.
* Simpify the supporting block code for the calls to MTLCopyAllDevicesWithObserver.
* Clean up the block we passed to MTLCopyAllDevicesWithObserver.
Removes the following warning during the builds:
```
warning CS8767: Nullability of reference types in type of parameter 'host' of 'bool NSHost.Equals(NSHost host)' doesn't match implicitly implemented member 'bool IEquatable<NSHost>.Equals(NSHost? other)' (possibly because of nullability attributes)
```
Test was added to ensure that we did not throw an exception.
- Added the marshaling attr and a test to ensure it is ok.
- Fix the cecil MarshalAs test to not skip over types when checking.
This revealed multiple tests failures that needed fixing.
fixes: https://github.com/xamarin/maccore/issues/2519
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
* Add support for the SupportedOSPlatformVersion MSBuild property, and write
it to the Info.plist for the corresponding minimum OS version.
* If there are any minimum OS version in the Info.plist, we'll now show an
error if it doesn't match SupportedOSPlatformVersion.
This unfortunately means that if there's any minimum OS version in any
Info.plist, then that will most likely have to be moved to the
SupportedOSPlatformVersion property (or removed entirely if that's the right
choice), since it's unlikely to match the default value for
SupportedOSPlatformVersion. However, this was deemed to be the best option for
the future (it's a one-time pain during migration).
Also add new tests, update existing tests, and update the templates.
Fixes https://github.com/xamarin/xamarin-macios/issues/12336.
Fixes this error when running on M1 (and Rosetta):
MonoTouchFixtures.CoreFoundation.BundleTest.TestGetBundleIdNull : 0.9134 ms
[FAIL] TestIsArchitectureLoadable : arm64 Expected => false
Expected: False
But was: True
at MonoTouchFixtures.CoreFoundation.BundleTest.TestIsArchitectureLoadable() in xamarin-macios/tests/monotouch-test/CoreFoundation/BundleTest.cs:line 375
* [xharness] Add LLVM test case for Mac Catalyst.
* [tests] Add make target to build monotouch-test using LLVM on Mac Catalyst.
* [tools] Pass the right arguments to the AOT compiler for Mac Catalyst. Fixes#12484.
Mac Catalyst is just special.
Fixes https://github.com/xamarin/xamarin-macios/issues/12484.
This test adds entries to the global reading list in Safari, and there's no
API for the test to clean up after itself, so the reading list becomes an
endless list of entries after a whlie.
Beside the fact that this is somewhat annoying for people who actually use
their reading lists, it can also can end up consuming a significant amount of
space on the hard drive, because Safari will download each site to be
available offline.
Fixes this test failure on device:
[FAIL] CurrentDirectory : Current directory at launch
Expected string length 97 but was 89. Strings differ at index 1.
Expected: "/private/var/containers/Bundle/Application/4824129A-8668-4CD9..."
But was: "/var/containers/Bundle/Application/4824129A-8668-4CD9-9280-7F..."
Fixes these test failures:
MonoTouchFixtures.HealthKit.CategoryTypeIdentifier
[FAIL] EnumValues_22351 : AppleWalkingSteadinessEvent could not be created: System.ArgumentNullException: Value cannot be null.
Parameter name: hkCategoryTypeIdentifier
at ObjCRuntime.NativeObjectExtensions.GetNonNullHandle (ObjCRuntime.INativeObject self, System.String argumentName) [0x00003] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/INativeObject.cs:27
at HealthKit.HKObjectType.GetCategoryType (Foundation.NSString hkCategoryTypeIdentifier) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/ios/native/HealthKit/HKObjectType.g.cs:111
at HealthKit.HKCategoryType.Create (HealthKit.HKCategoryTypeIdentifier kind) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/HealthKit/HKObjectType.cs:26
at MonoTouchFixtures.HealthKit.CategoryTypeIdentifier.EnumValues_22351 () [0x001fd] in /Users/builder/azdo/_work/1/s/xamarin-macios/tests/monotouch-test/HealthKit/CategoryTypeIdentifierTest.cs:115
at MonoTouchFixtures.HealthKit.CategoryTypeIdentifier.EnumValues_22351 () [0x0024f] in /Users/builder/azdo/_work/1/s/xamarin-macios/tests/monotouch-test/HealthKit/CategoryTypeIdentifierTest.cs:120
MonoTouchFixtures.HealthKit.QuantityTypeIdentifier
[FAIL] EnumValues_22351 : AppleWalkingSteadiness could not be created: System.ArgumentNullException: Value cannot be null.
Parameter name: hkTypeIdentifier
at ObjCRuntime.NativeObjectExtensions.GetNonNullHandle (ObjCRuntime.INativeObject self, System.String argumentName) [0x00003] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/ObjCRuntime/INativeObject.cs:27
at HealthKit.HKObjectType.GetQuantityType (Foundation.NSString hkTypeIdentifier) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/ios/native/HealthKit/HKObjectType.g.cs:162
at HealthKit.HKQuantityType.Create (HealthKit.HKQuantityTypeIdentifier kind) [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/HealthKit/HKObjectType.cs:19
at MonoTouchFixtures.HealthKit.QuantityTypeIdentifier.EnumValues_22351 () [0x0017a] in /Users/builder/azdo/_work/1/s/xamarin-macios/tests/monotouch-test/HealthKit/QuantityTypeIdentifierTest.cs:87
at MonoTouchFixtures.HealthKit.QuantityTypeIdentifier.EnumValues_22351 () [0x001cc] in /Users/builder/azdo/_work/1/s/xamarin-macios/tests/monotouch-test/HealthKit/QuantityTypeIdentifierTest.cs:92
Also make these tests show all failing enum values at once, instead of having
to run the test after adding each new case.
* Add support for the interpreter everywhere.
* Add support for the AOT compiler everywhere we didn't support it before,
because the interpreter needs it (at least System.Private.CoreLib.dll must
be AOT-compiled when using the interpreter).
* Do FullAOT compilation on Mac Catalyst/ARM64 if we're not using the
interpreter, since we can't use the JIT.
* Fix monotouch-test to be green on Mac Catalyst/ARM64.
Fixes https://github.com/xamarin/xamarin-macios/issues/11724.
Fixes https://github.com/xamarin/xamarin-macios/issues/11421.
Modifying the test to use UTC datetimes instead of local datetimes + specify
the timezone for the NSCalendar to make the results predictable everywhere and
at all times.
Fixes https://github.com/xamarin/maccore/issues/2471.
* [dotnet] Add support for implicit namespace imports. Fixes#12084.
Also update our templates to remove any using statements for implicitly imported
namespaces.
Fixes https://github.com/xamarin/xamarin-macios/issues/12084.
* [monotouch-test] Fix compilation error due to implicit namespace causing type conflict.
Fixes these errors:
xamarin-macios/tests/monotouch-test/ImageIO/MutableImageMetadataTest.cs(54,54): error CS0104: 'CGImageProperties' is an ambiguous reference between 'CoreGraphics.CGImageProperties' and 'ImageIO.CGImageProperties'
xamarin-macios/tests/monotouch-test/ImageIO/MutableImageMetadataTest.cs(54,88): error CS0104: 'CGImageProperties' is an ambiguous reference between 'CoreGraphics.CGImageProperties' and 'ImageIO.CGImageProperties'
xamarin-macios/tests/monotouch-test/ImageIO/ImageMetadataTest.cs(40,54): error CS0104: 'CGImageProperties' is an ambiguous reference between 'CoreGraphics.CGImageProperties' and 'ImageIO.CGImageProperties'
xamarin-macios/tests/monotouch-test/ImageIO/ImageMetadataTest.cs(40,88): error CS0104: 'CGImageProperties' is an ambiguous reference between 'CoreGraphics.CGImageProperties' and 'ImageIO.CGImageProperties'
* [monotouch-test] Check a few more permissions that sometimes make the app crash due to a TCC violation on Mac Catalyst.
* [monotouch-test] Adjust CaptureDeviceTest to only verify camera permission for Audio+Video, any other value is not supported by the OS.
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
* [monotouch-test] Create a shared.csproj for all the .NET monotouch-test project files.
Also complete the logic to build metal files, so that it works on Mac Catalyst as well.
* [monotouch-test] Add helper makefiles.
* [monotouch-test] Fix the RootTestsDirectory in the csproj.
* [monotouch-test] Add empty ItemGroup for xharness to put stuff in.
* [monotouch-test] Set DYNAMIC_REGISTRAR in each csproj, because xharness needs to be able to unset it.
* [monotouch-test] Exclude tests that don't work with AOT from Mac Catalyst/ARM64.
* [monotouch-test] Use 'ComputedPlatform' instead of 'Platform' to determine whether we're building for a device or not.
'Platform' can be anything, while we know the value of 'ComputedPlatform'. And
since 'ComputedPlatform' is computed after the csproj is read, we need to
delay the computation until later (thus in a separate target).