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.
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>
* 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>
* 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>
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.
* 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.
* 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>
* 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>
* 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>
* 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).
* 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.
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.
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.
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.
* 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>
* [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
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).
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.
* 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>
* [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>
* 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
- 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>