Граф коммитов

4634 Коммитов

Автор SHA1 Сообщение Дата
TJ Lambert 4f1ad9cb18
[sensorkit] Add nullability to (generated and manual) bindings (#14881)
Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
2022-05-04 11:43:54 -05:00
TJ Lambert 1e938b15d5
[replaykit] Add nullability to (generated and manual) bindings (#14863)
* nullable enable

* Use is null

Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
2022-05-03 10:51:35 -05:00
TJ Lambert d6bfa03fe4
[quicklookui] Add nullability to (generated and manual) bindings (#14862)
Co-authored-by: tj_devel709 <antlambe@microsoft.com>
2022-05-03 10:50:57 -05:00
TJ Lambert 86a312d86e
[photos] Add nullability to (generated and manual) bindings (#14861)
Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
2022-05-03 10:50:14 -05:00
TJ Lambert 0de0a2fd39
[printcore] Add nullability to (generated and manual) bindings (#14856)
* use better null exceptions

* add nullable enable

* Revert "add nullable enable"

This reverts commit 75909452e8.

* Add nullable enable without BOM

Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
2022-05-03 10:48:34 -05:00
Rolf Bjarne Kvinge 3dc90592b7
[dotnet] Use only the first two parts of our product version as the assembly version. (#14846)
This is a follow up to 92ee92eeb5, where we
changed the assembly version from four digits to three digits (i.e not include
the build number), because our managed API should be identical for (released)
versions where only the build number changes.

In this PR we go a bit further, because we're not supposed to have any API
differences unless the first two parts of the product version changes, which
means that we should only use need the two first parts of our product version
as the assembly version.
2022-05-03 10:07:11 +02:00
Chris Hamons 1dcefc9c56
[NET Attribute Conversion][generator] Generate NET style attributes (#14779)
This PR teaches our code generator to generate .NET 6 style availability attributes, adds a 4th Cecil test to verify our generated attributes, and a metric ton of API changes to satisfy that test.

The generator work is the core of this PR, and includes:

- Hacking out chunks of generator.cs that "helpfully" remove duplicate attributes, which are no longer duplicate in the new order that NET6 attributes force upon us. See changes in FilterMinimumVersion and PrintPlatformAttributes
- Prevent a crash when the generator processes availability attributes with no version included (example: introduced on iOS but no version). See Is64BitiOSOnly.
- The meat, GetPlatformAttributesToPrint, which synthesizes many attributes "out of thing air" from:
        - The parent context
        - Implied introduced just because the class exists on a given framework at all
        - Implied Catalyst because iOS exists
- A few cludgy hacks PrintPlatformAttributesNoDuplicates and GenerateProperty because the existing PrintPlatformAttributes did not pass down parent context down, and the refactor was dangerous/too time consuming given time pressure.

There are two intended API changes introduced by the reviews in this PR:

- GetCurrentInputDevice was obviously intended by availability attributes to exist on Catalyst but due to define confusion was excluded. It is an addition in Microsoft.MacCatalyst.dll only.
- The NEAppRule constructors were mis-marked on platforms, and were showing up incorrectly on Mac/Catalyst. I corrected the Catalyst one unconditionally, as we have not shipped Catalyst yet, but Mac is only fixed in NET6.

There is a lot of follow up work in https://github.com/xamarin/xamarin-macios/issues/14802 to do to remove a number of hard coded test failures, but this should be almost all of the remaining work in NET6 attributes.

🤞 this doesn't break too much for future us.

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-05-02 09:44:25 -05:00
Rolf Bjarne Kvinge c68ce23ac8
[ObjCRuntime] Specify the string comparison to use when comparing strings in Runtime.IsARM64CallingConvention. (#14840)
This may in some cases delay loading big chunks of .NET's globalization code
at startup until after reaching user's Main method.
2022-04-29 09:18:27 +02:00
TJ Lambert 6dc0eed0a8
[healthkit] Add nullability to (generated and manual) bindings (#14730)
* remove null ignores and add nullability

* throw better exception

* use is null

* remove extra ignores

* Add the tests

* use a progma ignore instead

* revert monotouch-test.csproj

Co-authored-by: tj_devel709 <antlambe@microsoft.com>
2022-04-28 11:54:23 -05:00
TJ Lambert 717b141f16
[gameplaykit] Add nullability to (generated and manual) bindings (#14615)
* adding Nullability

* throw better null exceptions

* use is null

* Added test

Co-authored-by: tj_devel709 <antlambe@microsoft.com>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
Co-authored-by: Alex Soto <alex@alexsoto.me>
2022-04-28 11:26:18 -05:00
Rolf Bjarne Kvinge ebe9f67548
[Foundation] Use ObjCRuntime.ThrowHelper in NSUrlSessionHandler. (#14823) 2022-04-27 08:32:28 +02:00
TJ Lambert bd4501ac88
[naturallanguage] Add nullability to (generated and manual) bindings (#14741)
* adding nullability changes

* throwing better exceptions

* using is null

* address Rolf and Manuel nullability changes

Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
2022-04-26 09:50:51 -05:00
Rolf Bjarne Kvinge 50283a8b97
[static registrar] Fix lookup of block proxy attributes. (#14820)
Fix lookup of block proxy attributes to look in protocols declared on base classes.

Broken pseudo code:

    class BaseApplicationDelegate : NSObject, IUIApplicationDelegate {}
    class MyApplicationDelegate : BaseApplicationDelegate {
        [Export("application:didReceiveRemoteNotification:fetchCompletionHandler:")]
        public void DidReceiveRemoteNotification (UIApplication application, NSDictionary userInfo, Action<UIBackgroundFetchResult> completionHandler) { }
    }

the static registrar wouldn't figure out that the DidReceiveRemoteNotification method
comes from the UIApplicationDelegate, because it would only look in protocols defined
on MyApplicationDelegate, not any base classes.

The fix is to look in base classes too.

Also:

* Fix a boolean logic error when matching parameters between methods in another
  (rarely used) code path when looking for matching binding methods in the extension
  class for protocols with optional members.
* Add tests.

Fixes https://github.com/dotnet/maui/issues/6259.
2022-04-26 13:47:18 +02:00
Alexander Köplinger 5c456d6dbb
Workaround FirstChanceExceptionEventArgs being trimmed (#14803)
* Workaround FirstChanceExceptionEventArgs being trimmed

See https://github.com/xamarin/xamarin-android/issues/6626

* Don't use ILLink descriptor on Microsoft.macOS.dll

It is using CoreCLR which doesn't run into the issue.
2022-04-25 08:07:24 +02:00
TJ Lambert 850db7a1a2
[pdfkit] Add nullability to (generated and manual) bindings (#14789)
Co-authored-by: tj_devel709 <antlambe@microsoft.com>
2022-04-22 15:55:23 -05:00
TJ Lambert 5522bc47f7
[gamecontroller] Add nullability to (generated and manual) bindings (#14612)
* Adding nullability

* use GetHandle ();

* Add nullable to TryGetX

Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-04-22 15:27:23 -05:00
TJ Lambert 6ccf756588
[avfoundation] Add nullability to (generated and manual) bindings - Fixed Branch (#14346)
* Nullability Changes

* Using is nulls

* This one shouldnt use is null

* Leave in the parameters that should not be null in the ignores

* Addressing Rolfs nullability fixes

* forgot this AVKit change

* More Concise nulls

* Silence the string nullability for AVAudioSession

* add if not null

* Use default value from apple docs for KeyToEnum method and correct earlier rolf suggestion

* Nullable element missing

* change default to null

* removing casting and passing the errors

* throw and exception in the setter

Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-04-22 15:26:19 -05:00
TJ Lambert 28fc8d262a
[networkextension] Add nullability to (generated and manual) bindings (#14788)
* enable nullability

* throw better exceptions

* use is null

Co-authored-by: tj_devel709 <antlambe@microsoft.com>
2022-04-21 11:35:09 -05:00
TJ Lambert 7fc37a4247
[network] Add nullability to (generated and manual) bindings (#14738)
* Throw better exceptions

* use is null and is not null

Co-authored-by: tj_devel709 <antlambe@microsoft.com>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-04-21 11:32:41 -05:00
TJ Lambert 4da970c41f
[nearbyinteraction] Add nullability to (generated and manual) bindings (#14735)
* nullable enable

* use is null

Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
2022-04-21 11:31:44 -05:00
Rolf Bjarne Kvinge 3afb12f692
[CoreCLR] Rework how we track the lifetime of managed NSObjects. (#14785)
* We now create a tracking GCHandle for all NSObjects, not only the toggled ones.
  CoreCLR will notify us when a tracked GCHandle's target enters finalization, and
  we need to be notified for all NSObjects, not just the toggled ones.
* Augment the tracking callback to know about non-toggled objects, and in that
  case report that the tracking GCHandle is a weak GCHandle.
* There's no need to store the tracking GCHandle in a field in the NSObject instance,
  since we store it in our runtime object_map.
* Remove one place where we set the InFinalizerQueue flag, since it's no longer
  required there (this reverts a previous attempt at fixing this problem - 0622ae4af2)
  - we only set the InFinalizerQueue flag in the xamarin_coreclr_reference_tracking_tracked_object_entered_finalization
  callback now.
* Update a few comments accordingly.

Partial fix for https://github.com/xamarin/xamarin-macios/issues/13531.

Fixes https://github.com/xamarin/xamarin-macios/issues/13921 (again).
2022-04-21 08:22:24 +02:00
Rolf Bjarne Kvinge 043a663ed2
[ObjCRuntime] Fix GCHandle leak in our NSObject map. (#14784)
* We can remove entries in the object_map when the target is null (and we
  don't need the corresponding GCHandle anymore, so it can be freed).
* When replacing an existing entry, we have to free the GCHandle.
2022-04-21 08:21:51 +02:00
Rolf Bjarne Kvinge 13b37cc090
[ObjCRuntime] Augment Runtime.GetNSObject to optionally create a new instance even if an existing instance was found. (#14783)
Augment Runtime.GetNSObject to optionally create a new instance even if an
existing instance was found, if the existing instance isn't compatible with
the requested instance type.

Partial fix for https://github.com/xamarin/xamarin-macios/issues/13531.
2022-04-21 08:21:32 +02:00
Rolf Bjarne Kvinge 7d229665c8
[runtime] Don't call 'retain' and 'autorelease' selectors on returned NativeObjects. (#14690)
We were trying to call the 'retain' and 'autorelease' selectors on objects
that weren't NSObjects when returning them from function calls. For some
unfathomable reason that has worked until now, but I started running into this
problem with other (unrelated) changes, so it needs to be fixed.

The fix is to not call the 'retain' and 'autorelease' selectors on
NativeObjects, instead call into managed code to either call the Retain method
on the managed NativeObject (if we're supposed to retain the return value), or
if we have to autorelease the return value, then check first if the input is
an NSObject, and only then call retain+autorelease.
2022-04-20 14:09:09 +02:00
Manuel de la Pena 1f1189fae0
[Foundation] Ensure that post requests are not cached by the native code.(#14729)
The behaviour from apple is wrong, PUT and POST are differnet in that PUT is idempotent.
Calling PUT several times successively has the same effect (that is no side effect),
where successive identical POST may have additional effects

We should not let the native code cache the calls.
2022-04-13 14:09:10 -04:00
TJ Lambert 8ef3850662
[coreml] Add nullability to (generated and manual) bindings (#14412)
* enable nullability

* use is null

* use an empty array

Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-04-11 09:16:54 -05:00
TJ Lambert 871b7858d8
[metrickit] Add nullability to (generated and manual) bindings (#14678)
Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
2022-04-08 09:04:18 -05:00
TJ Lambert c1a6b74c14
[mobilecoreservices] Add nullability to (generated and manual) bindings (#14677)
Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
2022-04-08 09:03:44 -05:00
TJ Lambert a0eeaec232
[messageui] Add nullability to (generated and manual) bindings (#14676)
* enable nullability

* use is null and is not null

Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
2022-04-08 09:03:05 -05:00
TJ Lambert 85b4c7a431
[metalkit] Add nullability to (generated and manual) bindings (#14695)
* add nullable enable

* use is null and is not null

Co-authored-by: tj_devel709 <antlambe@microsoft.com>
2022-04-08 08:57:10 -05:00
TJ Lambert aa98164c0f
[nativetypes] Add nullability to (generated and manual) bindings (#14694)
Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
2022-04-07 18:17:58 -05:00
TJ Lambert bd744db43d
[multipeerconnectivity] Add nullability to (generated and manual) bindings (#14680)
* enable nullability

* throw better exceptions

* use is null and is not null

Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
2022-04-07 18:16:40 -05:00
Chris Hamons cf77b790cb
[NET Attribute Conversion] Add missing attributes in code-behind by re-running conversion (#14660)
* [NET Attribute Conversion] Chip Framework
* [NET Attribute Conversion] Rerun with many fixes
* Fix generator crash when compiling attributes with no introduced version
* Test changes for availability re-run. One new test
2022-04-07 10:46:15 -05:00
Rolf Bjarne Kvinge 92ee92eeb5
[dotnet] Use only the first three parts of our product version as the assembly version. (#14679)
Problem:

* Assembly A is compiled referencing Microsoft.*.dll v1.0.0.123
* Assembly B is compiled referencing assembly A, and Microsoft.*.dll v1.0.0.0

The C# compiler doesn't like this, and says something like:

> error CS1705: Assembly 'A' with identity 'A, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'Microsoft.iOS, Version=1.0.0.123, Culture=neutral, PublicKeyToken=84e04ff9cfb79065' which has a higher version than referenced assembly 'Microsoft.iOS' with identity 'Microsoft.iOS, Version=1.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065'

The C# compiler is right: you need all your local references to be at least
the version of any indirect references, otherwise you're compiling using
outdated API.

On the other hand, we know that [1] we don't have any API differences (neither
additions nor removals) between stable versions of assemblies where only the
fourth digit is different.

In that case, the C# compiler error is just making things more complicated for
users, because if a upstream dependency is compiled with a newer (but
API-identical) version of Microsoft.*.dll, it forces all their users to update
as well.

The fix is to always use '0' as the fourth digit. That way the C# compiler
will accept different versions of any API-identical assemblies, and everybody
is happy [2].

[1]: We know that we _shouldn't_ have API changes when the fourth digit
changes. Hopefully we won't make any mistakes here...

[2]: However, for people using preview versions, there may very well be API
differences when the fourth digit changes. In that case, you're own your own,
and if the build breaks, you get to guess the actual problem and then figure
out the fix (which would usually be to use the latest version of the preview).
2022-04-07 08:06:56 +02:00
Rolf Bjarne Kvinge 6af4b9607c
[tools] Make the TargetFramework.DotNet* variables version-agnostic. (#14669)
This minimizes the code changes required for .NET 7.
2022-04-06 21:33:46 +02:00
Rolf Bjarne Kvinge 04993bc482
[src] Fix internal RemoveAttributesInstance directive for the linker. (#14667)
Fixes this warning:

>  Microsoft.MacCatalyst: The internal attribute name 'LinkerSafeAttribute' being used in the xml is not supported by the linker, check the spelling and the supported internal attributes.

It also probably fixes removal of the [Field] attribute.
2022-04-06 19:31:51 +02:00
TJ Lambert aa1733a623
[imageio] Add nullability to (generated and manual) bindings (#14633)
* add another nullability change

* Throw better exceptions

* use is null and is not null

Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-04-06 11:58:37 -05:00
TJ Lambert 138c966ea4
[javascriptcore] Add nullability to (generated and manual) bindings (#14658)
Co-authored-by: tj_devel709 <antlambe@microsoft.com>
2022-04-06 11:55:28 -05:00
TJ Lambert 032a2d47d6
[mediatoolbox] Add nullability to (generated and manual) bindings (#14664)
Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
2022-04-06 11:54:38 -05:00
TJ Lambert f01439ecab
[mediaaccessibility] Add nullability to (generated and manual) bindings (#14656)
* Adding nullability

* throwing better exceptions

* using is null

Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
2022-04-06 11:53:37 -05:00
TJ Lambert db6c2749c7
[mapkit] Add nullability to (generated and manual) bindings (#14640)
Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
2022-04-06 11:52:20 -05:00
Chris Hamons d51bd343f7
Add nullability on one UndoManager API (#14653)
- Fixes https://github.com/xamarin/xamarin-macios/issues/14646
- I checked UIDocument and AppKit versions and those are not nullable.
2022-04-06 10:43:29 -05:00
Alex Soto 132d5694d6
[ScreenCaptureKit] Add ScreenCaptureKit bindings up to Xcode 13.3 (#14644)
* [ScreenCaptureKit] Add ScreenCaptureKit bindings up to Xcode 13.3

* Use more appropriate exceptions.

* Remove ScreenCaptureKit from Mac Catalyst.

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2022-04-05 20:16:31 -04:00
TJ Lambert 9b605f7806
[mlcompute] Add nullability to (generated and manual) bindings (#14639)
Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
2022-04-05 11:23:45 -05:00
TJ Lambert 96a175cd5a
[inputmethodkit] Add nullability to (generated and manual) bindings (#14638)
Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
2022-04-05 11:23:06 -05:00
TJ Lambert 0fc655c7c4
[imagekit] Add nullability to (generated and manual) bindings (#14637)
Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
2022-04-05 11:22:33 -05:00
TJ Lambert 8cfd339998
[gamekit] Add nullability to (generated and manual) bindings (#14611)
Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
2022-04-05 11:19:22 -05:00
Chris Hamons 79d13f2478
Fix multiple API mistakes made in define removal (#14641)
* Fix multiple API mistakes made in define removal

* Revert "[Quicklook]Remove unnecessary conditional defines from quicklook.cs (#14491)"

This reverts commit ff048c38b0.

* Fix API breaks reverting quicklook PR
2022-04-05 09:50:14 -04:00
Chris Hamons 612c32ca20
[metalperformanceshaders] Add one troublesome missing method (#14557)
- Fixes https://github.com/xamarin/xamarin-macios/issues/14450
- There is a significant amount of additional bindings to be done, but this way
we at least get the trivia one in now.

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2022-04-04 11:08:55 -05:00
Chris Hamons 7c2ff23254
Remove unnecessary conditional defines from coreimage.cs (#14465)
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-04-04 11:07:48 -05:00