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

6693 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 5d4bff54b0
[AppKit] Make NSGraphics.NSBestDepth P/Invoke blittable. (#19614)
Also introduce a few other improvements:

* Add an varation that takes an 'out bool' instead of a 'ref bool'. According
  to the documentation the value is out-only.
* Name this variation according to our guidelines (with a verb).
* Deprecate the old version.

Contributes towards https://github.com/xamarin/xamarin-macios/issues/15684.
2023-12-13 12:55:25 +01:00
Rolf Bjarne Kvinge ad4c5c5a72
[tests] Fix detecting the runtime identifier for macOS tests executed on the command line. (#19592) 2023-12-13 12:52:29 +01:00
Manuel de la Pena 7ad1837e7d
[Metal] Add support for Xcode15. (#19379)
This PR brings all the changes from the new Metal APIs. During the
review pay special attention to the changes done in the Protocols in
order to add tvOS support.

The main problem we have had doing this PR is that tvOS was not done on
time before the NET branching, that left us with a lot of memebers that
were NOT added in tvOS that are abstract on dotnet, which has left use
in a pickle.

Lets use the following code as an example.

Code found before this commit:

```csharp
	[Mac (11, 0), iOS (14, 0), NoTV]
	[MacCatalyst (14, 0)]
#if NET
	[Abstract]
#endif
	[Export ("accelerationStructureCommandEncoder")]
	IMTLAccelerationStructureCommandEncoder CreateAccelerationStructureCommandEncoder ();
```

A naive approach would be to add just the tvOS suppor as follows:

```csharp
	[Mac (11, 0), iOS (14, 0), TV (16,0)]
	[MacCatalyst (14, 0)]
#if NET
	[Abstract]
#endif
	[Export ("accelerationStructureCommandEncoder")]
	IMTLAccelerationStructureCommandEncoder CreateAccelerationStructureCommandEncoder ();
```

The above change represents and API braking change on the donet tvOS dll
because it adds a new Abstrtact members, so this is no an acceptable
solution.

There is a second naive approach we can take which is as follows:

```csharp
	[Mac (11, 0), iOS (14, 0), TV (16,0)]
	[MacCatalyst (14, 0)]
#if NET &!TVOS
	[Abstract]
#endif
	[Export ("accelerationStructureCommandEncoder")]
	IMTLAccelerationStructureCommandEncoder CreateAccelerationStructureCommandEncoder ();
```

Yet again, the naive approach has an issue with it. In this case, all
the extension methods that are generated for tvOS (something the
generator writes when methods are not abstract) will be decorated with
availability attributes for all the other platforms, which is incorrect
and will make developers life worse.

That leaves us with the following approach:

```csharp
#if NET
#if !TVOS
	[Mac (11, 0), iOS (14, 0), NoTV, MacCatalyst (14, 0)]
	[Abstract]
#else
	[NoMac, NoiOS, TV (16,0), NoMacCatalyst]
#endif
#else
	[Mac (11, 0), iOS (14, 0), TV (16,0), MacCatalyst (14, 0)]
#endif
	[Export ("accelerationStructureCommandEncoder")]
	IMTLAccelerationStructureCommandEncoder CreateAccelerationStructureCommandEncoder ();
```

With the above change, we do not add an abstract method in tvOS and we
only add the tvOS abailabity attribute to the extension methods, and use
NoiOS etc for all the other platforms.

The change had to be done to ALL methods that added tvOS support. The
good news are that our cecil tests and our introspection tests catch the
two naive approaces :)

---------

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: Haritha Mohan <harithamohan@microsoft.com>
Co-authored-by: Alex Soto <alex@alexsoto.me>
2023-12-12 17:39:56 -05:00
Manuel de la Pena 5cca8aa1cf
[CoreMidi] Add CoreMidi enums to Watch so that we can have them for avfoundation. (#19580)
Similar to https://github.com/xamarin/xamarin-macios/pull/19529 we need
this for all the avfoundation to be landed.

---------

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
2023-12-07 12:32:32 -05:00
Rolf Bjarne Kvinge d4e49a53d2
[xharness] Fix a few minor code issues + wrong copyright. (#19583) 2023-12-07 08:05:39 +01:00
Rolf Bjarne Kvinge eb3c561e7b
[msbuild] Parse --nowarn and --warnaserror from MtouchExtraArgs for .NET. (#19540) 2023-12-06 17:27:17 +01:00
Rolf Bjarne Kvinge 107d644b55
[xharness] Convert to .NET. (#19541)
* Convert xharness.csproj and Xharness.Tests.csproj to .NET/sdk-style projects.
* Fix numerous nullability issues that came up.
* Adjust Make logic to do the correct thing now that the executable is named differently.
* Port usage of WebClient to HttpClient, since WebClient is deprecated.
* Find an alternative solution to System.Web.MimeMapping.GetMimeMapping, which
  doesn’t exist in .NET.
* Fix misc other warnings and errors.
2023-12-06 15:57:12 +01:00
Rolf Bjarne Kvinge 1ddc0b4b74
Get Mono.Cecil from NuGet everywhere. (#19535)
Also:

* Store the version in Directory.Build.props, which makes it much easier to update.
* Bump all versions to latest (0.11.5).
2023-12-04 20:15:03 +01:00
Rolf Bjarne Kvinge a9c9598820
[msbuild] Detect any dylibs in NativeReferences. Fixes #19520. (#19560)
We add the dylib location as an rpath if the app has any location, so make
sure to correctly detect dylibs in native references.

Fixes https://github.com/xamarin/xamarin-macios/issues/19520.
2023-12-04 20:11:20 +01:00
Rolf Bjarne Kvinge b09ac67cfc
[tests] Ignore network-related failures in UrlConnectionTest.SendSynchronousRequest. (#19567) 2023-12-04 17:03:43 +01:00
Manuel de la Pena 16ac6b14fe
[Generator] Clean the AttributeManager from deps and fix a bug in the errors. (#19532)
Remove the need to pass the BT. More importantly fix an issue with the
errors when more than one attribute was expected. The eng that wrote the
code did not consider translations, and therefore the current errors
seen by a non-english speaker will result in part of the error in her
native language and the rest in english. On top of that, in english the
error is broken with words repited or broken sentences.

---------

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
2023-12-04 07:08:16 -05:00
Rolf Bjarne Kvinge d77105b3a9
[tests] Make it easier to run tests from the command line with NativeAOT. (#19559) 2023-12-04 08:45:10 +01:00
Rolf Bjarne Kvinge bcbc4f8dfd
[tests] Fix an issue with the ProjectTest.InvalidArchProperty test. (#19549)
It seems targets are ran in a different order in .NET 9, which means that we
ran into a different one that the one we expected. So fix that error, which
means we're now getting the error the test is checking for again.

Fixes:

    Xamarin.Tests.DotNetProjectTest.InvalidArchProperty(TVOS,"MtouchArch","arm64"): Error count
        Expected: 1
        But was: 2

    Xamarin.Tests.DotNetProjectTest.InvalidArchProperty(MacCatalyst,"MtouchArch","x64"): Error count
        Expected: 1
        But was: 2

    Xamarin.Tests.DotNetProjectTest.InvalidArchProperty(MacOSX,"XamMacArch","x64"): Error message
        Expected string length 172 but was 50. Strings differ at index 0.
        Expected: "The property 'XamMacArch' is deprecated, please remove it fro..."
        But was: "Could not parse TargetArchitectures 'x64'\n "
        -----------^

    Xamarin.Tests.DotNetProjectTest.InvalidArchProperty(iOS,"MtouchArch","armv7s"): Error count
        Expected: 1
        But was: 2

Also improve error reporting a bit.
2023-12-04 08:25:41 +01:00
Rolf Bjarne Kvinge 0e42551756
[tests] Port the ModelMustBeProtocol test from monotouch-test to cecil-test. (#19561)
It uses reflection, so it upsets NativeAOT, so just move it to cecil-test instead.

This will make it run faster, and also more predictable (it's supposed to
check all types, but types in monotouch-test may have been linked away).

Ref: https://github.com/dotnet/runtime/issues/95444
2023-12-04 08:25:07 +01:00
Manuel de la Pena d5f62b2758
[CoreMidi] Add support for tvOS. (#19529)
Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
2023-11-30 13:25:34 -05:00
Rolf Bjarne Kvinge a736e683ae
[AppKit] Update the NSBezelStyle enum according to latest headers. Fixes #19555. (#19556)
Fixes https://github.com/xamarin/xamarin-macios/issues/19555.
2023-11-30 15:58:13 +01:00
Šimon Rozsíval 40c3f422c4
[NativeAOT] Improve the transformation of [Preserve(AllMembers = true)] (#19516)
Closes #19505 

We transform `[Preserve(AllMembers = true)]` into
`[DynamicDependency(DynamicallyAccessedMemberTypes.All, typeof(T))]`.
There is difference between which members are preserved in these two
cases. The `DynamicallyAccessedMemberTypes.All` preserves many more,
especially nested types and their members. This manifested with the
`IL3050` AOT analysis warning we got from ILC when building any app:
1. `NSObject_Disposer` has `[Preserve(AllMembers = true)]`
2. `NSObject_Disposer` is a subclass of NSObject
3. `NSObject` has nested enums `Flags` and `XamarinGCHandleFlags`
4. the base class `Enum` has a public static method `GetValues(Type)`
5. the `GetValues` method is annotated with `RequiresDynamicCode` and
ILC produces a warning because even though it isn't used anywhere in the
codebase, it could be used via reflection

I changed two things when transforming Preserve:
- For enums, we only need to preserve public fields. We especially want
to avoid `PublicMethods` since that would preserve public methods in the
base class which includes the `GetValues(Type)` method.
- For other types, I list explicitly the member types that should be
preserved instead of using `All`.
- The code is verbose, but in the end, I chose the explicit list instead
of `All ^ PublicNestedTypes ^ NonPublicNestedTypes` since that would
automatically include any new flag added to the enum in the future.
2023-11-30 11:39:27 +01:00
Rolf Bjarne Kvinge 3f9e00cb27
[install-source] Migrate project to use PackageReference instead of package.config. (#19536) 2023-11-29 16:23:34 +01:00
Rolf Bjarne Kvinge 0e1509cbba
[tests] Set RuntimeIdentifier in CollectAppManifestsTests.PartialAppManifest (#19533)
Make RuntimeIdentifier explicit in
CollectAppManifestsTests.PartialAppManifest, because we later try to look for
a path that depends on the runtime identifier, and setting the runtime
identifier explicitly is easier than figuring out the default runtime
identifier (which depends on the host architecture).

Fixes this failure on arm64 machines:

    1) Failed : Xamarin.MacDev.Tasks.CollectAppManifestsTests.PartialAppManifest
      App manifest existence
      Expected: file or directory exists
      But was:  "xamarin-macios/tests/msbuild/Xamarin.MacDev.Tests/bin/Debug/net472/tmp-test-dir/Xamarin.MacDev.Tasks.CollectAppManifestsTests.PartialAppManifest/bin/Debug/net8.0-macos/osx-x64/PartialAppManifest.app/Contents/Info.plist"
      at Xamarin.MacDev.Tasks.CollectAppManifestsTests.PartialAppManifest () [0x0011d] in xamarin-macios/tests/msbuild/Xamarin.MacDev.Tests/TargetTests/CollectAppManifestsTests.cs:71
2023-11-29 10:55:34 +01:00
Manuel de la Pena f214469111
[Generator] The Nomenclator does know how to get the name of a type. (#19530)
Moved the method to the right object and add tests.

---------

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
2023-11-28 11:12:50 -05:00
Rolf Bjarne Kvinge 2652f49694
Bump MSBuild.StructuredLogger to v2.2.100 (#19503)
Also store the version globally to avoid having to update so many places
in future bumps.
2023-11-28 15:15:29 +01:00
Simon Rozsival 5c57994acd Fix CMBlockBufferCustomBlockSource on NativeAOT 2023-11-27 11:33:08 +01:00
Rolf Bjarne Kvinge c82b9de7e9
[msbuild] Fix resolving static libraries inside an XCFramework in a NuGet. (#19502)
The ResolveNativeReferences task would incorrectly set Kind=Framework for static
libraries and dylibs if these files came from an XCFramework in the runtimes/native
directory in a NuGet (as opposed to a binding project, or the NuGet built from a
binding project).

Fix this by properly assigning the Kind and PublishFolderType metadata for such static
libraries and dylibs.

Also add a test.
2023-11-27 08:54:48 +01:00
Simon Rozsival 7a45bad062 Update test 2023-11-24 14:51:40 +01:00
GitHub Actions Autoformatter 7a39369644 Auto-format source code 2023-11-23 14:19:08 +00:00
Simon Rozsival 635ef072c9 Change the transformation of Preserve attribute into DynamicDependency 2023-11-23 14:08:31 +01:00
Rolf Bjarne Kvinge a648b6951f
[CoreText] Fix a few nullability issues in CTFontDescriptor. (#19439) 2023-11-21 07:59:13 +01:00
Rolf Bjarne Kvinge 4beb0cd549
[Foundation] Fix a few issues with NSUrlConnection.SendSynchronousRequest. (#19458)
There's no need to bind this method manually anymore, so just add it to
our bindings.

Hopefully fixes #19289.
2023-11-20 14:14:29 +01:00
Rolf Bjarne Kvinge 8cd685d448
[InputMethodKit] Remove existing code for InputMethodKit. (#19462)
No InputMethodKit bindings are included in the build, so just remove the
bindings we have, since it's confusing to have code we don't build/use.

See also https://github.com/xamarin/xamarin-macios/issues/7487.
2023-11-20 07:55:13 +01:00
Rolf Bjarne Kvinge eeb0aaaf19
Update the Mono.Options package references to the same (latest) version everywhere. (#19457) 2023-11-16 14:01:45 +01:00
Manuel de la Pena dd3aa9afca
[Generator] Move the most of the path logic out of BT. (#19429)
Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
2023-11-15 16:38:48 -05:00
Rolf Bjarne Kvinge 5c1f372e81
[tests] Don't pass a message to Assert.Ignore. (#19453)
When run in the terminal using 'dotnet test', the text passed to
Assert.Ignore is show in red, which makes it look like a failure and is
always confusing.

Before:

![Screenshot 2023-11-15 at 10 59
29](https://github.com/xamarin/xamarin-macios/assets/249268/dbc0f4f4-660a-41b7-96fc-84a7d132a880)

After:

![Screenshot 2023-11-15 at 11 06
35](https://github.com/xamarin/xamarin-macios/assets/249268/2a5e60b0-6d9b-41db-ba18-4717e39827a5)
2023-11-15 18:12:58 +01:00
Rolf Bjarne Kvinge f3aa9ceea7
[tests] Add a cecil-test to verify capitalization. (#19443)
Add a cecil test to verify a few common capitalization issues:

* All APIs must start with an upper-cased letter (except parameter names, which must start with a lower-cased letter).
* The term "URL" should always be capitalized as "Url".
2023-11-15 17:09:07 +01:00
Manuel de la Pena 59a2e49b28
[Tests] Fix CALayer tests on Sonoma. (#19450)
Sonoma is pickier now with the way we create a CoreGraphics.CGImage,
meaning that if we do not pass the correct flags, the OS will return a
nil object (might be a good idea to move away from constructors to
factory methods).

Before this change we would get the following errors:

* CAKeyFrameAnimation_ValuesTests: System.Exception : Could not
initialize an instance of the type 'CoreGraphics.CGImage': handle is
null. It is possible to ignore this condition by setting
ObjCRuntime.Class.ThrowOnInitFailure to false.

* CALayer_ValuesTests: System.Exception : Could not initialize an
instance of the type 'CoreGraphics.CGImage': handle is null. It is
possible to ignore this condition by setting
ObjCRuntime.Class.ThrowOnInitFailure to false.
2023-11-15 11:05:56 -05:00
Manuel de la Pena 9d259a539d
[monotouch-tests] Fix HK tests on sonoma. (#19446)
Before this commit we had the following failing test:

```
Error: Exception Message
Expected: String matching "Objective-C exception thrown. Name: _HKObjectValidationFailureException Reason: Type HKSample can not have endDate of NSDate.distantFuture"
But was: "Objective-C exception thrown. Name: _HKObjectValidationFailureException Reason: startDate (0001-01-01 00:00:00 +0000) and endDate (4001-01-01 00:00:00 +0000) exceed the maximum allowed duration for this sample type. Maximum duration for type
```

The new exception does not happen on macOS but does on iOS.
2023-11-14 11:15:13 -05:00
Rolf Bjarne Kvinge f4d6a7ea46
[tools] Don't detect/resolve binding resource packages in mtouch/mmp/dotnet-linker. Fixes #19378. (#19407)
We currently detect/resolve binding resource packages (the sidecar) in two places:

* The ResolveNativeReferences MSBuild task.
* Inside mtouch/mmp/dotnet-linker.

Which means we end up passing every native library or framework twice to the native linker.

This is usually not a problem, the native linker will ignore duplicated
arguments, except when building remotely from Windows, in which case the build
process may end up with native libraries in different locations, because files
may end up in multiple places on the remote Mac if using absolute paths (see
https://github.com/xamarin/xamarin-macios/issues/18997 for a thorough explanation).

So completely remove the logic to detect/resolve binding resource packages in
mtouch/mmp/dotnet-linker, which will avoid the issue completely.

A few mtouch tests also needed updating, since they're calling mtouch directly instead
of going through the msbuild targets.

Fixes https://github.com/xamarin/xamarin-macios/issues/19378.
2023-11-13 16:38:23 +01:00
Rolf Bjarne Kvinge bc57444487
[tests] Revert workaround for bug in MSBuild[.StructuredLogger]. Fixes #18568. (#19414)
We no longer need this workaround.

Fixes https://github.com/xamarin/xamarin-macios/issues/18568.
2023-11-10 08:13:20 +01:00
Rolf Bjarne Kvinge c309661cca
[CoreText] Implement CTFontDescriptor.MatchFontDescriptors. Fixes #19397. (#19399)
Fixes https://github.com/xamarin/xamarin-macios/issues/19397.
2023-11-09 09:11:14 +01:00
Rolf Bjarne Kvinge ad7996ee7b
Add the .NET TFM as a constant to the generated SdkVersions.cs from our Makefile variables. (#19401)
This way we can avoid hardcoding the TFM in a few more places.
2023-11-08 13:36:50 +01:00
dustin-wojciechowski b4da42958d
[Generator] Refactor Format Type methods into TypeManager class (#19331)
First take at refactoring parts of the Generator:

1. RemoveArity() is now a string extension method with a test
2. FormatType, FormatTypeUsedIn, and part of PrimitiveType methods have
been moved into the TypeManager class.
3. TypeManager now has access to BindingTouch (similar to the other
Manager classes) so that it may call methods from NamespaceManager,
which also had to be made into a public property of BindingTouch vs
being passed through the Generator constructor.

---------

Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
Co-authored-by: Alex Soto <alex@alexsoto.me>
2023-11-01 09:40:00 -07:00
Haritha Mohan 8908fa13d7
[Vision] Add support for Xcode 15 (#19099)
Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
Co-authored-by: Alex Soto <alex@soto.dev>
2023-10-31 13:20:59 -07:00
Haritha Mohan ca35f94b1f
[GameKit] Add support for Xcode 15 (#19285)
Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
2023-10-31 13:20:38 -07:00
Rolf Bjarne Kvinge 2534418caa
[tests] Try to fix a few random test failures in UserDefaultsTests. (#19354)
Try to fix a few random test failures in UserDefaultsTests by making sure they
won't fail if another process is running the test at the same time by adding
the PID to any machine-wide identifiers.

Might fix:

* https://github.com/xamarin/maccore/issues/2488
* https://github.com/xamarin/maccore/issues/2725
2023-10-27 08:09:58 +02:00
Manuel de la Pena d9f5a2bfb5
[UIKit] Add support for Xcode 15. (#19120)
Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
Co-authored-by: Haritha Mohan <harithamohan@microsoft.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: TJ Lambert <50846373+tj-devel709@users.noreply.github.com>
2023-10-25 12:41:17 -04:00
Rolf Bjarne Kvinge c4e4a2c8cf
[msbuild] Fix parsing single-char mtouch extra args of the form '-vvvv'. (#19318) 2023-10-25 08:44:54 +02:00
Rolf Bjarne Kvinge 85ddcf2006
[dotnet] Remove support for MtouchArch and XamMacArch. (#19319)
When migrating Xamarin projects to .NET projects, somewhat frequently people
will leave the MtouchArch/XamMacArch properties in their project files with
old values. This won't work, since we use RuntimeIdentifier(s) now to control
the target architecture, so remove support for MtouchArch/XamMacArch, and show
an error if we detect that they're set.

This will hopefully prevent some really confusing problems, especially in the IDEs.

Example: https://github.com/xamarin/xamarin-macios/issues/19258
2023-10-25 08:33:06 +02:00
Manuel de la Pena 16e915424d
[Storekit] Add support for xcode 15. (#19309)
Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
2023-10-24 07:59:49 -04:00
Manuel de la Pena f9fb647e8e
[AppKit] Add support for Xcode 15. (#19119) 2023-10-23 21:39:29 -04:00
Manuel de la Pena f181a1d744
[MacCatalyst] Fix intro failures in catalyst on sonoma. (#19308) 2023-10-23 21:28:02 -04:00
TJ Lambert 6d30e583d3
[PassKit] Add support Xcode15 Beta 7 (#19139)
The bindings for PassKit Xcode15 Beta 7.

---------

Co-authored-by: tj_devel709 <antlambe@microsoft.com>
2023-10-23 13:05:19 -05:00