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

6991 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 7e54b16412
[dotnet] Delay computing trimming options until MAUI has had a chance to change the default. (#20970)
See comment in code for a deeper explanation.

Partial fix for https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2053707.

---------

Co-authored-by: Alex Soto <alex@soto.dev>
2024-08-07 14:43:53 +02:00
Rolf Bjarne Kvinge 47137d670a
[xtro] Enable Mac Catalyst. (#20974)
It didn't work at some point, but seems to be working fine now.

---------

Co-authored-by: Alex Soto <alex@soto.dev>
2024-08-06 19:49:43 +02:00
Alex Soto 76769f17d5
[main] Enable dedup only when targeting arm64 (#20953)
Backport of https://github.com/xamarin/xamarin-macios/pull/20952

--------

## Description

Previous fix https://github.com/xamarin/xamarin-macios/pull/20945 did
not take into account that when we target non arm64 apple mobile
platforms we are using `MONO_AOT_MODE_INTERP_ONLY` which cannot use
dedup optimization as it discards AOT images during runtime.

## Changes

- Enable dedup only when targeting ARM64
- Fix tests to cover builds for both ARM64 and X64 builds

Finally, the change was tested against MAUI iossimulator-x64 template
app

---------

Co-authored-by: Ivan Povazan <ivan.povazan@gmail.com>
Co-authored-by: Ivan Povazan <55002338+ivanpovazan@users.noreply.github.com>
2024-07-30 08:10:22 -04:00
Ivan Povazan 40a8eba6bf
Do not enable dedup when targeting `maccatalyst-x64` (#20945)
## Description

This is a follow-up PR to:
https://github.com/xamarin/xamarin-macios/pull/20936

We should not enable dedup when targeting `maccatalyst-x64` because in
case when the project file specifies
`MtouchInterpreter=all,-System.Private.CoreLib`, the build will run the
full AOT compiler with interpreter enabled.

In this setup the runtime is configured to run in interp only mode:
97a91cc4e3/tools/common/Target.cs (L812-L813)

which means that during runtime, AOT images will be ignored - aot
runtime will load them but mark them as unusuable since they are
compiled with `full` compiler switch and the code falls back to
interpreter (ref:
efebf202a4/src/mono/mono/mini/aot-runtime.c (L2131-L2148)
)

This is problematic for the `aot-instances` container image, which has a
special handling at the runtime and does not accept it to be marked as
unusable (we might want to revisit this in the future):

efebf202a4/src/mono/mono/mini/aot-runtime.c (L2527-L2529)

## Changes

This PR disables dedup optimization when targeting `maccatalyst-x64` and
updates the required tests to match the behavior.

---

Backports:

- [x] https://github.com/xamarin/xamarin-macios/pull/20946
- [x] Original reenabling of dedup for .NET 9 already includes these
changes: https://github.com/xamarin/xamarin-macios/pull/20941

---------

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
2024-07-26 18:44:07 -04:00
Ivan Povazan 97a91cc4e3
Reenable dedup optimization for all AOT modes (#20936)
## Description

As part of the fix for: https://github.com/dotnet/runtime/issues/99248
we disabled dedup optimization in partial/hybrid AOT mode (when both
interpreter and AOT compiler are enabled). This change got backported to
.NET 8 and with the latest servicing release regressed build times and
app sizes significantly as reported in:
https://github.com/xamarin/xamarin-macios/issues/20848

However, it turns out that disabling dedup optimization is not required
to fix https://github.com/dotnet/runtime/issues/99248 but instead we
should correct the Xamarin SDK integration with this optimization which
this PR is doing. The following section describes the initial problem in
more details.

## Overview of AOT modes and dedup optimization

When the repro project from
https://github.com/dotnet/runtime/issues/99248 is built with dedup
enabled in hybrid AOT+interpreter mode, the app crashes with:
```
024-07-23 14:32:37.524110+0200 IvansApp[12711:20244208] debug: AOT NOT FOUND: (wrapper other) object:gsharedvt_out_sig (intptr).
2024-07-23 14:32:37.524120+0200 IvansApp[12711:20244208] error: * Assertion at /Users/ivan/repos/runtime-mono-iOS/src/mono/mono/mini/interp/interp.c:2667, condition `is_ok (error)' not met, function:init_jit_call_info, Attempting to JIT compile method '(wrapper other) void object:gsharedvt_out_sig (intptr)' while running in aot-only mode. See https://learn.microsoft.com/xamarin/ios/internals/limitations for more information.
```

To track down why these wrappers which are used to transition from
interpreter to AOT code, are not generated we need to understand when
they are compiled in different AOT modes with and without dedup
optimization enabled:

- In full AOT setup - all assemblies AOT compiled
    - `gsharedvt_out_sig` methods are never generated

- In hybrid AOT + interpreter setup - all assemblies AOT compiled:
`MtouchInterpreter=-all`
    - Dedup OFF:
- `gsharedvt_out_sig` methods are generated in AOT images of every
assembly (to enable interpreter calling into each specific assembly -
here wrappers with same signatures are duplicated)
    - Dedup ON:
- `gsharedvt_out_sig` methods are generated only in `aot-instances` AOT
image
- during AOT compilation of individual assemblies generation of
`gsharedvt_out_sig` is skipped
- during AOT compilation of `aot-instances` assembly we collect all
`gsharedvt_out_sig` variants from the full program scope and generate
code for them in `aot-instances` AOT image

- In hybrid AOT + interpreter setup - all assemblies interpreted except
a given assembly: `MtouchInterpreter=all,-MyAssembly`
    - Dedup OFF:
- `gsharedvt_out_sig` methods are generated in AOT image of `MyAssembly`
(to enable interpreter calling into it)
    - Dedup ON: <- $${\color{red} ISSUE }$$ 
- `gsharedvt_out_sig` methods *should* be generated only in
`aot-instances` AOT image, but the `aot-instances` image is missing
    - explanation:
- what happens is that generation of `gsharedvt_out_sig` is skipped
during AOT compilation of `MyAssembly` (as expected).
- But, the build does not mark `aot-instances` assembly as the one that
should be AOT compiled.
- The reason for this is that we have a global `_IsDedupEnabled` flag,
but when custom linker step analysis `aot-instances.dll` it does not see
it as an assembly which should not be interpreted.
- To explain that better: we mark *all* assemblies as to be interpreted
(via: `MtouchInterpreter=all`), but exclude only `MyAssembly` (via:
`MtouchInterpreter=all,-MyAssembly`).
- So when custom linker step processes `aot-instaces.dll` it treats it
as an assembly to be interpreted, so it does not mark it for AOT
compilation.
- This further results with `aot-instances` AOT image missing, and all
the methods which we skipped during AOT compilation never get generated.

## The fix

To fix this and address regressions reported in:
https://github.com/xamarin/xamarin-macios/issues/20848 we are reenabling
dedup optimization whenever AOT compilation is requested and fixing the
issue where the custom linker step for generating AOT parameters always
treates the dedup assembly as the one to be AOTed.

Once approved this should be backported to .NET 8 as servicing releases
are also affected with it.

---------

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
2024-07-25 19:50:21 -04:00
Rolf Bjarne Kvinge d1ec7a793f
[tests] Fix determining whether we're building for the simulator or not. (#20852)
The 'Platform=iPhoneSimulator' property is not necessarily set for .NET
projects, so don't rely on it.
2024-07-12 18:46:17 +02:00
Rolf Bjarne Kvinge 01400da900
[xtro] Get libclang-mono.dylib from where sharpie is. (#20815)
This fixes a crash when using a locally built sharpie - in which case we
shouldn't use the system libmono-clang.dylib, but the locally built one too.
2024-07-12 18:40:21 +02:00
Rolf Bjarne Kvinge 219c74a3c4
[xcode15.4] Update bindings to Xcode 15.4 (#20865)
Co-authored-by: Alex Soto <alex@soto.dev>
2024-07-11 14:09:52 -04:00
Alex Soto 2e5ef1eb1c
[xcode15.3] Bump to Xcode 15.3 bindings (#20780)
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2024-07-11 11:41:31 +02:00
Rolf Bjarne Kvinge 4fd259d4dc
[tests] Simplify NWPathTest.EnumerateGatewayTest (#20853)
* Remove code to test NWPath.EnumerateInterfaces, because this method is already tested elsewhere.
* Assume that if the test fails to find any gateways, it might be because the
  current machine doesn't have any (which happens on one of my machines), and
  in that case ignore the test.
2024-07-10 21:40:50 +02:00
Rolf Bjarne Kvinge b3fc0d93ec
[src] Implement a more generic way of calling objc_msgSend with variadic arguments. (#20832)
Move the architecture-specific vargs implementation of UIAppearance.GetAppareance into a more generic way of calling objc_msgSend with variadic arguments.

This prepares the way for more APIs with variadic arguments (which is coming in Xcode 16).
2024-07-10 21:19:51 +02:00
Rolf Bjarne Kvinge ed77cd6224
[dotnet] Limit custom dotnet/runtime selection to the current .NET version. (#20840)
This way any tests using the previous .NET version still works.
2024-07-10 16:30:34 +02:00
Rolf Bjarne Kvinge 7ddf1284a5
[dotnet] Force 'AppendRuntimeIdentifierToOutputPath=true' for the inner build of universal apps. (#20839)
When building universal apps, each inner build must add the runtime identifier to the output path, otherwise the inner builds may conflict with eachother, overwriting eachother's files.

That's bad.

So we explicitly set `AppendRuntimeIdentifierToOutputPath` to `true` when building inner builds.
2024-07-10 13:00:05 +02:00
Rolf Bjarne Kvinge 180a7e0bb9
[tests] Fix a couple of minor issues. (#20843)
* xtro: Fix how we build the u2todo project to actually build the correct project.
* Don't import eng/Versions.props in several test projects, it's already imported in a Directory.Build.props further up the directory hierarchy.
2024-07-10 12:57:30 +02:00
Rolf Bjarne Kvinge c81cb4aa77
[xtro] Move xtro-sharpie.csproj to its own directory. (#20825)
This will make it easier to eventually migrate this project to .NET.
2024-07-09 16:25:39 +02:00
Rolf Bjarne Kvinge 1520e0ebbc
[tests] Update 'KnownFrameworkReference' and 'KnownRuntimePack' to the reference the correct dotnet/runtime version when using a custom dotnet/runtime. (#20838) 2024-07-09 14:17:58 +02:00
Rolf Bjarne Kvinge 26ede64161
[tests] Make the generator tests in the Makefile use the locally installed Xamarin.iOS/Xamarin.Mac. (#20821) 2024-07-08 18:30:36 +02:00
Rolf Bjarne Kvinge ddaf7822f9
[devops] Copy XMA's NuGet.config to XMA's home directory. (#20819)
This way we're using the same NuGet configuration even when executing outside
of XMA's .NET directory.

Also collect a bit more diagnostic info.
2024-07-08 18:30:21 +02:00
Rolf Bjarne Kvinge 544b96817f
[xtro] Fix version comparison with macOS 10.7. (#20816)
This also required updating the xtro files.
2024-07-08 18:30:14 +02:00
Rolf Bjarne Kvinge 9582522ccb
[xtro] Convert most projects to .NET projects. (#20760)
Convert all projects except xtro-sharpie.csproj to .NET projects.
xtro-sharpie.csproj can't be converted yet, because it depends on
Objective-Sharpie, which hasn't been converted yet.
2024-07-05 14:54:29 +02:00
Rolf Bjarne Kvinge c930ab321b
[monotouch-test] Remove ignore for Mac Catalyst. (#20810)
Apple says the bug on their side causing a runtime crash has been fixed since
macOS 12, so unignore the code and add a version check for macOS 12.

Fixes https://github.com/xamarin/maccore/issues/2345.
2024-07-04 14:16:38 +02:00
Rolf Bjarne Kvinge 6da82734ee
[src/tools] Propagate the BackwardsCompatibleCodeGeneration field from Protocol attributes in bindings to the generated code. (#20804)
Also fix the MustSetBackwardsCompatibleCodeGenerationToFalse test to skip
protocols that actually set BackwardsCompatibleCodeGeneration=false.
2024-07-03 20:18:13 +02:00
Rolf Bjarne Kvinge 323d28c220
[Foundation] Make the generic collection classes' generic GetEnumerator methods public. (#20808)
When finding an enumerator for the given code:

```cs
var collection = new NSSet<NSNumber> ();
foreach (var item in collection) {
	// ...
}
```

the C# compiler will first look for any `GetEnumerator` methods. The non-generic `NSSet` class defines a `IEnumerator<NSObject> GetEnumerator<NSObject> ()` method, which, since the generic `NSSet<T>` class doesn't define such a method, is selected.

The end result is that the type of the foreach element is `NSObject`
(`GetEnumerator`'s return type') - which is somewhat unexpected:

```cs
var collection = new NSSet<NSNumber> ();
foreach (var item in collection) {
	Console.WriteLine (item.LongValue); // error CS1061: 'NSObject' does not contain a definition for 'LongValue'
}
```

The fix is to define a  `IEnumerator<T> GetEnumerator<T> ()` method in the
generic `NSSet<T>` class, which the C# will find and choose over the base
class' method. Then the type of the foreach element is the correct type, and
the following code works:

```cs
var collection = new NSSet<NSNumber> ();
foreach (var item in collection) {
	Console.WriteLine (item.LongValue); // it works!
}
```

Do this for all our generic collection classes.

Also document these methods + all the other public `GetEnumerator` methods.
2024-07-03 20:16:53 +02:00
Rolf Bjarne Kvinge a28cf64a8c
[msbuild] Don't support RuntimeIdentifiers for Hot Restart. (#20750)
There's no need to support `RuntimeIdentifiers` (plural) for Hot Restart
(because we don't have any scenarios where multiple runtime identifiers
applies to iOS; a single runtime identifier can always be used).

Adding support would make our code base more complex, so just avoid it by
showing an early error if someone tries (which is likely to be accidental
anyways).

This way we show an actionable error message for a scenario customers will
probably be confused about (because the build would fail in rather
inexplicable ways) if they run into it.

Partial fix for https://github.com/xamarin/xamarin-macios/issues/19262.
2024-07-01 19:26:57 +02:00
Rolf Bjarne Kvinge 5f7792ab91
[tests] Fix BuildBindingsTest expectations. (#20768)
Fix BuildBindingsTest expectations to expect the resources in either a sidecar or a zipped sidecar.

Fixes this test failure:

    Xamarin.Tests.DotNetProjectTest.BuildBindingsTest(TVOS): Bundle existence
    Expected: file or directory exists
    But was: "/Users/builder/azdo/_work/1/s/xamarin-macios/tests/bindings-test/dotnet/tvOS/bin/Debug/net8.0-tvos/bindings-test.resources.zip"
2024-06-27 09:38:12 +02:00
Rolf Bjarne Kvinge 9b7ff19b47
[src] Fix definition of AVSampleCursorAudioDependencyInfo for Mac Catalyst. (#20781)
We need the backwards compatible code for the
AVSampleCursorAudioDependencyInfo struct (i.e. use the
AVSampleCursorAudioDependencyInfo_Blittable version), so adjust the ifdefs
accordingly - which wasn't obvious at first, because __IOS__ is defined for
Mac Catalyst.

Also fix the corresponding test, because it would cache the result of
computing whether a struct was blittable or not, but that's not true across
platforms ("AVSampleCursorAudioDependencyInfo" is blittable on iOS, but not on
Mac Catalyst). The result was that the test would incorrectly pass if we
processed Microsoft.iOS.dll before Microsoft.MacCatalyst.dll. The fix is to
cache per platform, instead of using a global cache.
2024-06-26 14:17:58 +02:00
Rolf Bjarne Kvinge 2f9ddc1933
[Foundation] Add missing properties to NSCharacterSet. Fixes #20745. (#20761)
Fixes https://github.com/xamarin/xamarin-macios/issues/20745.
2024-06-21 18:37:16 +02:00
Rolf Bjarne Kvinge 10f3b5ae32
[tests] Convert the testgenerator.csproj to a .NET project. (#20740) 2024-06-19 15:10:54 +02:00
Rolf Bjarne Kvinge 6c2a7a9eac
[msbuild] The DTPlatformName is supposed to be 'macosx' for Mac Catalyst. (#20720)
Change how we compute DTPlatformName so that it's 'macosx' for Mac Catalyst.
The PlatformUtils.GetTargetPlatform returns SdkPlatform for all platforms
except Mac Catalyst, where it returns the same as for macOS (i.e. 'macosx').
It also returns a lowercased value, so we don't need to do that either.

This is a partial fix for https://github.com/xamarin/xamarin-macios/issues/20714.
2024-06-17 20:19:06 +02:00
Rolf Bjarne Kvinge 9c2bd68d92
[src] Remove a few MarshalAs attributes in various APIs. (#20704)
In these cases the APIs in question aren't used in P/Invokes at the moment,
but that may change, so just make as much as we can blittable by removing any
MarshalAs attributes.
2024-06-10 19:11:47 +02:00
Rolf Bjarne Kvinge 1216646909
[runtime] Use strnlen instead of strlen. (#20702)
Apparently it's safer.
2024-06-10 13:02:42 +02:00
Rolf Bjarne Kvinge 3ab838ef6d
[GameController] Make a few structs blittable. (#20697)
Make a few GameController structs blittable, which requires some workarounds
to the fact that these changes would be breaking changes - we're keeping the
old structs, and instead introduce internal blittable versions which are then
used in the api definitions (and thus generated P/Invokes).
2024-06-10 11:52:24 +02:00
Rolf Bjarne Kvinge 34f58bbed4
[runtime] Use calloc instead of malloc. (#20692)
It's safer, since the returned memory is zero-initialized.

Also add tests.
2024-06-07 16:56:54 +02:00
Rolf Bjarne Kvinge e9d59d5f58
[bgen] Implement support for using default interface members to bind protocols. (#20681)
Given the following API definition:

```cs
[Protocol]
public interface Protocol {
    [Abstract]
    [Export ("requiredMethod")]
    void RequiredMethod ();

    [Export ("optionalMethod")]
    void OptionalMethod ();
}
```

we're now binding it like this:

```cs
[Protocol ("Protocol")]
public interface IProtocol : INativeObject {
    [RequiredMember]
    [Export ("requiredMethod")]
    public void RequiredMethod () { /* default implementation */ }

    [OptionalMember]
    [Export ("optionalMethod")]
    public void OptionalMethod () { /* default implementation */ }
}
```

The main difference from before is that the only difference between required
and optional members is the [RequiredMember]/[OptionalMember] attributes.

This has one major advantage: it's now possible to switch a member from being
required to being optional, or vice versa, without breaking neither source nor
binary compatibility.

It also improves intellisense for optional members. In the past optional
members were implemented using extension methods, which were not very
discoverable when you were supposed to implement a protocol in your own class.

The main downside is that the C# compiler won't enforce developers to
implement required protocol members (which is a necessary side effect of the
fact that we want to be able to switch members between being required and
optional without breaking compatibility). If this turns out to be a problem,
we can implement a custom source analyzer and/or linker step that detects
missing implementations and issue warnings/errors.

This PR also:

* Adds numerous tests.
* Updates the requiredness of a few members in Metal to test that it works as
  expected.
* Adds documentation.
* Handles numerous corner cases, which are documented in code and docs.

This PR is probably best reviewed commit-by-commit.

Fixes https://github.com/xamarin/xamarin-macios/issues/13294.
2024-06-07 16:35:48 +02:00
Milos Kotlar 603781b63f
Enable dedup optimization in FullAOT mode only (#20687)
## Description

This PR enables the dedup optimization in FullAOT mode only. The
optimization can only run in FullAOT mode with complete application
context. Without it, the AOT compiler may fail to collect all generic
instances, and the runtime can't find them as they are searched in the
dedup assembly.

## Changes

This PR updates the SDK targets to enable dedup optimization in FullAOT
mode only. This change doesn't depend on any runtime changes.

## Verification

This PR also introduces partial AOT tests. They inspect the bundle for
`aot-instances.dll`, which shouldn't be generated in a partial AOT
compilation setup. Additionally, basic functionality is tested by
asserting at app startup.

## Additional notes

This change should be backported to .NET 8 as well.

Fixes https://github.com/dotnet/runtime/issues/99248
2024-06-07 13:21:41 +02:00
Rolf Bjarne Kvinge ae155a9798
[AVFoundation] Numerous improvements to the AVSampleCursor type + some other structs. (#20685)
* The AVSampleCursor type was made available on all platforms two years ago (as
  opposed to only macOS before that), so update availability attributes accordingly.

* Also make a few structs used by AVSampleCursor blittable (AVSampleCursorSyncInfo,
  AVSampleCursorDependencyInfo, AVSampleCursorChunkInfo, AVSampleCursorAudioDependencyInfo)

  This got a bit complicated, because some of the non-blittable members of these structs
  are public. This meant a workaround had to be implemented:

  * Rename the properties that use these structures - appending "_Blittable" - and
    make them internal.
  * Create internal "*_Blittable" versions of the structures, and a make the "_Blittable"
    properties return these structures.
  * Bind the properties again, wrapping the internal versions and manually converting
    from the blittable structures to the non-blittable structures.

  Note that since some of the properties are new on iOS and tvOS, we don't need the
  compatibility workaround for these platforms.

Contributes towards #15684.
2024-06-06 17:19:17 +02:00
Rolf Bjarne Kvinge 7670afb6aa
[src/docs] Add xml documentation for types. (#20672)
Import all the xml documentation for types from https://github.com/xamarin/apple-api-docs.

Some of this documentation should probably be rewritten, and potentially moved
to conceptual documentation, in particular those that contain images (because
images can't be imported into xml documentation).

Note that the documentation hasn't been modified in any way; that's not the purpose of this PR. If documentation should be modified for whatever reason, it can be done in a later PR.

The xml documentation for members will come in a later PR.

Partial fix for https://github.com/xamarin/xamarin-macios/issues/17399.
2024-06-06 07:37:52 +02:00
Rolf Bjarne Kvinge 5566f4912c
[cecil-tests] Fix blittability check for parameters whose types are pointers. (#20683) 2024-06-05 14:04:14 +02:00
Rolf Bjarne Kvinge 9657179d8c
[cecil-tests] Add new test to verify that we don't have any MarshalAs attributes. (#20678)
This is mostly to ensure that in XAMCORE_5_0 we fix all APIs with MarshalAs
attributes, because in order to not break binary compatibility, we can't fix
all of these failures right now.

Additionally it ensures we don't add more APIs with MarshalAs attributes.
2024-06-04 16:38:43 +02:00
Rolf Bjarne Kvinge 05a9b0872f
[src] Make a few P/Invokes stragglers have blittable signatures. (#20675)
Contributes towards #15684.
2024-06-04 14:51:51 +02:00
Rolf Bjarne Kvinge aa25b1e191
[tests] Fix BundleStructure when building for only tvOS. (#20677)
Fix BundleStructure when building for only tvOS by detecting whether the
bindings are zipped or not by detecting the presence of the zip file, instead
of computing it based on the current platform (which becomes problematic,
because whether or not a binding project produces a zip file may depend on
whether other platforms are enabled or not).
2024-06-04 09:07:51 +02:00
Rolf Bjarne Kvinge 5557fa32bc
[Network] Make the remaining P/Invokes have blittable signatures. (#20668)
Contributes towards #15684.
2024-06-03 14:29:01 +02:00
Rolf Bjarne Kvinge 5c5a4580ec
[Network] Make P/Invokes in NWConnection[Group] have blittable signatures. (#20662)
Contributes towards #15684.
2024-05-31 13:24:20 +02:00
Rolf Bjarne Kvinge 7b3ad09aac
[bgen] Add support for binding static members in protocols. (#20645)
Add support for binding static members in protocols.

Given the following API definition:

```cs
[Protocol]
public interface Protocol {
    [Abstract]
    [Static]
    [Export ("requiredStaticMethod")]
    void RequiredStaticMethod ();

    [Static]
    [Export ("optionalStaticMethod")]
    void OptionalStaticMethod ();

    [Abstract]
    [Static]
    [Export ("requiredStaticProperty")]
    IntPtr RequiredStaticProperty { get; set; }

    [Static]
    [Export ("optionalStaticProperty")]
    IntPtr OptionalStaticProperty { get; set; }
}
```

we're binding it like this:

```cs
[Protocol ("Protocol")]
public interface IProtocol : INativeObject {
    [Export ("requiredStaticMethod")]
    public static void RequiredStaticMethod<T> () where T: NSObject, IProtocol { /* implementation */ }

    [Export ("optionalStaticMethod")]
    public static void OptionalStaticMethod<T> () where T: NSObject, IProtocol { /*  implementation */ }

    [Property ("RequiredStaticProperty")]
    [Export ("requiredStaticProperty")]
    public static IntPtr GetRequiredStaticProperty<T> () where T: NSObject, IProtocol { /* implementation */ }

    [Property ("RequiredStaticProperty")]
    [Export ("setRequiredStaticProperty:")]
    public static void SetRequiredStaticProperty<T> (IntPtr value) where T: NSObject, IProtocol { /* implementation */ }

    [Property ("OptionalStaticProperty")]
    [Export ("optionalStaticProperty")]
    public static IntPtr GetOptionalStaticProperty<T> () where T: NSObject, IProtocol { /* implementation */ }

    [Property ("OptionalStaticProperty")]
    [Export ("setOptionalStaticProperty:")]
    public static void SetOptionalStaticProperty<T> (IntPtr value) where T: NSObject, IProtocol { /* implementation */ }
}
```

Also add documentation and tests.
2024-05-31 13:00:57 +02:00
Rolf Bjarne Kvinge 3efa6c21ff
[tests] Skip framework-test on iOS and tvOS. (#20590)
This test doesn't work when building on iossimulator-arm64 or
tvossimulator-arm64, because we're trying to use a fat framework which doesn't
have that architecture (it contains the device arm64 architecture instead).

So just disable this test on iOS and tvOS - the solution is using an
xcframework, and we already have a different test for that.

---------

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2024-05-30 10:34:14 +02:00
Rolf Bjarne Kvinge 13cec0c657
[AppKit] Improve bindings for NSPasteboard and NSPasteboardReading a bit. (#20643)
* Create strong enums for NSPasteboardType and NSPasteboardName.
* Bind the NSPasteboardReading constructor.

Ref: https://github.com/xamarin/xamarin-macios/issues/14039
2024-05-30 08:23:54 +02:00
Rolf Bjarne Kvinge 36bc43f7dc
[CryptoTokenKit] Bind this framework. Fixes #7876. (#20587)
Fixes https://github.com/xamarin/xamarin-macios/issues/7876.

---------

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2024-05-29 20:38:40 +02:00
Rolf Bjarne Kvinge a0b858ad47
[runtime] Call mono_unhandled_exception to raise AppDomain.UnhandledException. (#20656)
Call mono_unhandled_exception to raise AppDomain.UnhandledException when
managed exceptions are unhandled.

Partial fix for #15252 (for MonoVM, still pending for CoreCLR, which
needs https://github.com/dotnet/runtime/issues/102730 fixed first).
2024-05-29 20:14:47 +02:00
Rolf Bjarne Kvinge 1c7604cde2
[Network] Make P/Invokes in NW*Descriptor and NWWebSocket* have blittable signatures. (#20659)
Contributes towards #15684.
2024-05-29 19:20:54 +02:00
Rolf Bjarne Kvinge 2100580024
[Network] Make P/Invokes in NWFramer[Message] have blittable signatures. (#20647)
Contributes towards #15684.
2024-05-29 11:25:34 +02:00