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

17320 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 9feebdcfac
[PrintCore] Make P/Invokes have blittable signatures. (#20542)
Contributes towards #15684.
2024-05-01 10:28:23 +02:00
Rolf Bjarne Kvinge 37c11cf0a1
[tools] Don't require a LinkWith attributes to find Objective-C classes in assemblies. (#20479)
Stop requiring a LinkWith attribute in an assembly in order to keep any Objective-C
types within. There are many ways to include a native library in a build nowadays,
and more and more often they don't need any LinkWith attributes to specify custom
linker behavior (in particular for frameworks, which can typically be included as-is).
The result of not searching such assemblies for Objective-C types would be that the
native linker would strip them away, and that would mean incorrect behavior at runtime.

However, this is a rather invasive change, especially for a minor release, so I'm
adding two things to make it better:

1. An opt-out MSBuild property: `RequireLinkWithAttributeForObjectiveCClassSearch`.
   Set to 'true' to opt-out (default is 'false').

2. Improve handling of native symbols with regards to the native linker.

    Add a new item group, ReferenceNativeSymbol, that contains native symbols
    we handle in some way - either to be ignored or we ask the native linker
    to keep it (by passing it as '-u ...' or in a symbol list file).

    There are two supported types of metadata:

    * SymbolType: either 'ObjectiveCClass', 'Function' or 'Field'. Used to
      compute the complete native name of a symbol (for instance, the native
      symbol for the Objective-C class "MyClass" is `_OBJC_CLASS_$_MyClass`,
      while for a function "MyFunction" it's just `_MyFunction`.
    * SymbolMode: either 'Ignore' or 'Default'. "Ignore" means to not pass the given
      symbol to the native linker, the default is to do so.

    SymbolType is required, while SymbolMode isn't.

    Example symbol to keep:

    ```xml
    <ItemGroup>
        <ReferenceNativeSymbol Include="MyClass" SymbolType="ObjectiveCClass" />
    </ItemGroup>
    ```

    Example symbol to ignore:

    ```xml
    <ItemGroup>
        <ReferenceNativeSymbol Include="MyClass" SymbolType="ObjectiveCClass" SymbolMode="Ignore" />
    </ItemGroup>
    ```

Finally use the latter solution to work around an issue that arouse with monotouch-test:
we reference an Objective-C class that doesn't exist in monotouch-test. This worked
because the referencing assembly didn't have a LinkWith attribute (and thus the reference
was ignored), but now that the reference isn't ignored anymore, we need to explicitly
ignore the Objective-C class.
2024-05-01 08:31:47 +02:00
Rolf Bjarne Kvinge 2b33d4d49b
[Foundation] Make P/Invokes have blittable signatures. (#20539)
Contributes towards #15684.
2024-05-01 08:31:10 +02:00
Rachel Kang de511013c4
Update README (#20536)
Update README in preparation for May 1
2024-05-01 08:29:31 +02:00
Manuel de la Pena 836577b81b
[CI] Use extensions for the run tests pipelines. (#20537)
Use extensions so that the entry point yaml is simpler to maintain.
2024-04-30 15:37:57 -04:00
Rolf Bjarne Kvinge f9aa441e4a
[tests] Don't verify that property accessors have xml documentation. (#20538)
There's no way to add xml documentation to them.

Partial fix for https://github.com/xamarin/xamarin-macios/issues/20270.
2024-04-30 19:35:47 +02:00
Manuel de la Pena 1be0fe3c62
[CI] Simplify the split of the pipelines via extensions (#20535)
Make the live of the mantianers better by using inheritance for the
build pipelines. This later will make the move to the 1ES template
easier since we refactored the yaml of the pipelines to be as small as
possible.
2024-04-30 12:35:34 -04:00
Rolf Bjarne Kvinge eb5948fedd
[msbuild] Set the working directory before executing 'dotnet build' in the ComputeRemoteGeneratorProperties task. (#20506)
If the project in question needs a custom NuGet.config, this NuGet.config file
will be in a base directory of where the .NET executable is located. I'm not
certain what the current directory is when executing `dotnet` in this task, so
make it explicit in case it's a different path.

This in particular might affect us for remote tests using .NET previews:

    /Users/builder/Library/Caches/Xamarin/mtbs/builds/bindingsframeworktest/8b36a8b30efab69178e7774426ff34b9aded7e20a789eb18f485be2f81a2dccd/obj/Debug/net9.0-ios/ComputeRemoteGeneratorProperties/ComputeRemoteGeneratorProperties.csproj : error NU1102: Unable to find package Microsoft.NET.ILLink.Tasks with version (>= 9.0.0-preview.4.24223.11)
    /Users/builder/Library/Caches/Xamarin/mtbs/builds/bindingsframeworktest/8b36a8b30efab69178e7774426ff34b9aded7e20a789eb18f485be2f81a2dccd/obj/Debug/net9.0-ios/ComputeRemoteGeneratorProperties/ComputeRemoteGeneratorProperties.csproj : error NU1102:   - Found 21 version(s) in nuget.org [ Nearest version: 9.0.0-preview.3.24172.9 ]
      Failed to restore /Users/builder/Library/Caches/Xamarin/mtbs/builds/bindingsframeworktest/8b36a8b30efab69178e7774426ff34b9aded7e20a789eb18f485be2f81a2dccd/obj/Debug/net9.0-ios/ComputeRemoteGeneratorProperties/ComputeRemoteGeneratorProperties.csproj (in 424 ms).
2024-04-30 18:29:52 +02:00
Rolf Bjarne Kvinge da6e1af4b1
[msbuild] Enable nullability in a few tasks. (#20509) 2024-04-30 18:29:44 +02:00
dotnet-maestro[bot] 8980649e46
[main] Update dependencies from dotnet/xharness (#20532)
This pull request updates the following dependencies

## From https://github.com/dotnet/xharness

- **Subscription**: 601bc5e1-1cae-44b5-cf5f-08db9342aa2f
- **Build**: 20240424.1
- **Date Produced**: April 24, 2024 12:20:37 PM UTC
- **Commit**: ec633d9ddbdb86dd3d772989889690821f790484
- **Branch**: refs/heads/main

- **Updates**:
  - **Microsoft.DotNet.XHarness.iOS.Shared**: [from 9.0.0-prerelease.24208.1 to 9.0.0-prerelease.24224.1][1]

[1]: 50b43ece7d...ec633d9ddb
2024-04-30 14:34:35 +02:00
Rolf Bjarne Kvinge 8bb2048f5f
[GameController] Make P/Invokes have blittable signatures. (#20528)
Contributes towards #15684.
2024-04-30 08:56:20 +02:00
Haritha Mohan ac22d6f3c6
[ADR] Bump maccore to get property docs fix (#20517)
Ref: https://github.com/xamarin/maccore/pull/2788

---------

Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2024-04-29 21:04:45 -07:00
Manuel de la Pena c2c09d7a02
[CI] Split tests to a post-build pipeline. (#20534)
1Es is problematic and has a lot of issues on how we use the matrix
strategies. We have two options, either wait for 1ES to implement the
needed changes or move all the tests out to two different pipelines that
won't need to be 1ES complient.

In the long run moving out of the build piepline is going to give us
more flexibility and will move the project away from depending on a
thridparty to fix the yaml issues.

Even when landing this PR we will not have the tests removed, we will do
that after we have been able to test that things work as expected.
2024-04-29 18:14:12 -04:00
Rolf Bjarne Kvinge 8692511232
[devops] Remove installation of .NET 5. (#20527)
It doesn't look like we need it anymore, and in any case it fails to
install on ARM64:

> ##[error]Download URL for .Net Core sdk version 5.0.408 could not be
found for the following OS platforms (rid): osx-arm64,osx-arm64

From:
https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=9486716&view=logs&jobId=2ad83a99-f770-5ec5-96c6-63e16b4bb697&j=2ad83a99-f770-5ec5-96c6-63e16b4bb697&t=5c4dfcb8-6d0a-532a-9705-12b94c390bf5
2024-04-29 20:03:39 +02:00
Rolf Bjarne Kvinge 526fdc9437
[devops] Fix API scan when there are no enabled .NET platforms. (#20477) 2024-04-29 16:31:29 +02:00
Rolf Bjarne Kvinge 16d9ece88e
[devops] Escape Rosetta when installing powershell. (#20530)
If the script to install powershell is executed with Rosetta, this happens:

    $ arch -x86_64 brew install powershell
    Warning: Not upgrading powershell, the latest version is already installed
    Error: Cannot install under Rosetta 2 in ARM default prefix (/opt/homebrew)!
    To rerun under ARM use:
        arch -arm64 brew install ...
    To install under x86_64, install Homebrew into /usr/local.

which can be seen on the bots:
https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=9496253&view=logs&j=1acdac53-199e-5330-5c52-bf5d9d7be24b&t=ca94b18d-fa43-5a35-82db-a681bd2b1a78.

So escape Rosetta when installing powershell.
2024-04-29 16:30:46 +02:00
Rolf Bjarne Kvinge 3a623d1227
[GLKit] Make the GLKVertexAttributeParametersFromModelIO P/Invoke have a blittable signature. (#20529)
This was complicated a bit because it uses a non-blittable struct we can't
change because it's public API. So introduce an internal temporary blittable
struct.

Contributes towards #15684.
2024-04-29 16:29:56 +02:00
Rolf Bjarne Kvinge 7292983fbf
[bgen] Generate xml documentation for generated default constructors. (#20525)
This was mostly copied from the existing API documentation.

Partial fix for https://github.com/xamarin/xamarin-macios/issues/20270.
2024-04-29 12:05:12 +02:00
Rolf Bjarne Kvinge b540a0a914
[devops] Clean up a few more temporary logs before doing remote tests. (#20508) 2024-04-29 10:37:02 +02:00
Rolf Bjarne Kvinge d617aa9aae
[OpenGL/OpenGLES] Make P/Invokes have blittable signatures. (#20512)
Contributes towards #15684.
2024-04-29 09:33:38 +02:00
Rolf Bjarne Kvinge 641475d328
[CoreVideo] Make P/Invokes in CVPixel related types have blittable signatures. (#20510)
Contributes towards #15684.
2024-04-29 09:29:54 +02:00
Rolf Bjarne Kvinge 771453d8a4
[bgen] Generate xml documentation for generated enums. (#20511)
This was mostly copied from the existing API documentation.

Partial fix for https://github.com/xamarin/xamarin-macios/issues/20270.
2024-04-26 14:50:24 +02:00
Emanuel Fernandez Dell'Oca 0071fb3dc3
Bump Xamarin.Messaging 1.14.6 (#20514)
---------

Co-authored-by: Emanuel Fernandez Dell'Oca <ema@xamarin.com>
2024-04-26 13:31:08 +02:00
Rolf Bjarne Kvinge 0f7e11120a
Bump Xamarin.MacDev. (#20518)
New commits in xamarin/Xamarin.MacDev:

* xamarin/Xamarin.MacDev@4cb9dc2 [Xamarin.MacDev] Use Stream.ReadExactly instead of Stream.Read when we can.
* xamarin/Xamarin.MacDev@e707772 Use RandomNumberGenerator instead of System.Random

Diff: d1ed5a2dbb..4cb9dc2632
2024-04-26 09:09:10 +02:00
Rolf Bjarne Kvinge 3744c76391
[bgen] Generate xml documentation for generated UIAppearance logic. (#20502)
This was mostly copied from the existing API documentation.

Partial fix for https://github.com/xamarin/xamarin-macios/issues/20270.
2024-04-25 13:53:34 +02:00
Rolf Bjarne Kvinge a36a0f8922
[devops] Each test run shouldn't take more than a couple of hours, so set 3h as the upper bound. (#20496)
Waiting 16.6 hours for a test run to time out if something goes wrong is way too long.
2024-04-25 12:37:06 +02:00
Rolf Bjarne Kvinge fd3361ba34
[src] Expand multi-field single statements into multiple statements. (#20489)
This is in preparation for XML documentation: in order to provide XML
documentation for each field, they need to be separate statements.
2024-04-25 11:00:41 +02:00
Rolf Bjarne Kvinge 3ca9851df7
[CoreVideo] Make P/Invokes in CVImageBuffer and CVMetalTexture[Cache] have blittable signatures. (#20500)
Contributes towards #15684.
2024-04-25 10:59:44 +02:00
Rolf Bjarne Kvinge 2d278f672d
[bgen] Fix support for ErrorDomain enums in third-party bindings. (#20499)
The generator needs a library name for the generated `_domain` field.

Here's an example for the generated `ARErrorCodeExtensions` class ("ARKit" is
the library name):

```cs
[Field ("ARErrorDomain", "ARKit")]
static NSString? _domain;
```

In order to find the library name, the generator would look at the first enum
field with a `[Field]` attribute, and get the `LibraryName` property from that
`[Field]` attribute. Unfortunately error enums don't necessarily have `[Field]`
attributes on their enum fields. This works fine for our own bindings, because
the generator will fall back to the enum's namespace, but for third-party
bindings this would be the result:

> error BI1042: bgen: Missing '[Field (LibraryName=value)]' for ErrorDomainNS.EWithDomain. (e.g."__Internal")

Note that the error message is rather confusing: it's trying to report a
missing `LibraryName` property for a `[Field]` attribute, but there's no `[Field]`
attribute anywhere in the enum in question.

So fix this by:

* Adding the `LibraryName` property on the `[ErrorDomain]` attribute.
* Implement support for looking at this new property in the generator.
* Report a better error if it's not there.
2024-04-25 10:52:50 +02:00
Rolf Bjarne Kvinge 6c19986225
[SearchKit] Make P/Invokes have blittable signatures. (#20493)
Contributes towards #15684.
2024-04-24 13:19:08 +02:00
Rolf Bjarne Kvinge cb34348455
[CoreVideo] Make P/Invokes in CVBuffer and CVDisplayLink have blittable signatures. (#20494)
Contributes towards #15684.
2024-04-24 12:01:43 +02:00
Alexander Köplinger 45449a0c4b
Use legacy mono-sdks from download.mono-project.com (#20482)
---------

Co-authored-by: Alexander Köplinger <alex.koeplinger@outlook.com>
2024-04-24 10:35:21 +02:00
Rolf Bjarne Kvinge 1e0cc8f0fb
[docs] Review and update the 'Binding errors' document. (#20481)
Note that this document is currently not published on our documentation web site.

* Consolidate on a single way to specify message arguments (* instead of {...}).
* Mark messages that will only be show in legacy as such (but keep them)
* Escape star characters in headers.
* Remove mentions of Xamarin.
* Misc other updates.
2024-04-24 09:41:10 +02:00
Rolf Bjarne Kvinge 70a5d0d09a
[msbuild] Improve the UnpackLibraryResources task a bit. (#20004)
* Unpack into a per-assembly directory. This way identically named resources from
  different assemblies won't overwrite eachother.

* Remove logic to detect overwriting of existing bundle resources, because it's broken.

     In particular this piece of code is missing a single character (there should be a `!` in the condition):

     ```cs
     if (string.IsNullOrEmpty (logicalName))
         ignore.Add (logicalName);
     ```

    This means we're only ignoring bundle resources without LogicalName, which shouldn't
    happen. So just remove the code, since it doesn't do anything useful. A proper fix
    for resource collision is in progress and will come in a separate pull request.

* Fix task to work for incremental builds. Previously we'd detect that any resources
  had been extracted and not re-extract, but we wouldn't add those extracted resources
  to the `_BundleResourceWithLogicalName` item group. The end result would be that
  on incremental builds, any bundled resources wouldn't be picked up at all. Typically
  this wouldn't be a problem (because the resources would be in the resulting app
  bundle), but doing anything out of the ordinary could cause problems. The fix is
  to write the unpacked items + their metadata to a file, and load those when we
  detect that no re-extraction is necessary (this file also does double duty as a
  stamp file in the code).

* Augment `WriteItemsToFile` to make its `Write` method accessible from different classes.

* Improve logging a bit.
2024-04-24 09:40:45 +02:00
Rolf Bjarne Kvinge 8b3ce01c2c
[bgen] Generate xml documentation for notifications. (#20492)
This was mostly copied from the existing API documentation.

Partial fix for https://github.com/xamarin/xamarin-macios/issues/20270.
2024-04-24 09:36:14 +02:00
Rolf Bjarne Kvinge 0f23bcda3c
[Darwin] Make the 'kevent' P/Invoke have blittable signatures. (#20467)
Contributes towards #15684.
2024-04-23 18:13:13 +02:00
Rolf Bjarne Kvinge b410d74248
[msbuild] Improve errors in case native linking fails. (#20462)
By default we limit the error message to 1024 characters in case the native
linker fails. The problem is that the native linker may show a lot of warnings
in the beginning, so if that happened, the error output would show only a list
of warnings and nothing else, which is rather confusing.

So change the output slightly when reporting an error in the native linker:

* Try to filter out warnings.
* Show a max of 25 lines of errors (as opposed to 1024 characters, which tended to be 3-4 lines).

So now instead of this error:

    [...]/targets/Xamarin.Shared.Sdk.targets(1623,3): clang++ exited with code 1:
    ld: warning: object file ([...]/packs/Microsoft.NETCore.App.Runtime.Mono.maccatalyst-arm64/8.0.3/runtimes/maccatalyst-arm64/native/libSystem.Globalization.Native.a(pal_calendarData.c.o)) was built for newer Mac Catalyst version (14.2) than being linked (14.0)
    ld: warning: object file ([...]/packs/Microsoft.NETCore.App.Runtime.Mono.maccatalyst-arm64/8.0.3/runtimes/maccatalyst-arm64/native/libSystem.IO.Compression.Native.a(pal_zlib.c.o)) was built for newer Mac Catalyst version (14.2) than being linked (14.0)
    ld: warning: object file ([...]/packs/Microsoft.NETCore.App.Runtime.Mono.maccatalyst-arm64/8.0.3/runtimes/maccatalyst-arm64/native/libSystem.IO.Compression.Native.a(constants.c.o)) was built for newer Mac Catalyst versio

we get:

    [...]/targets/Xamarin.Shared.Sdk.targets(1623,3): clang++ exited with code 1:
    Undefined symbols for architecture arm64:
      "__swift_FORCE_LOAD_$_swiftCompatibility56", referenced from:
          __swift_FORCE_LOAD_$_swiftCompatibility56_$_main in libSwiftTest.a(libSwiftTest.arm64.o)
         (maybe you meant: __swift_FORCE_LOAD_$_swiftCompatibility56_$_main)
      "__swift_FORCE_LOAD_$_swiftCompatibilityConcurrency", referenced from:
          __swift_FORCE_LOAD_$_swiftCompatibilityConcurrency_$_main in libSwiftTest.a(libSwiftTest.arm64.o)
         (maybe you meant: __swift_FORCE_LOAD_$_swiftCompatibilityConcurrency_$_main)
    ld: symbol(s) not found for architecture arm64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)

which makes much more sense for an error.

The full linker output is still available in the build log if needed.
2024-04-23 17:03:37 +02:00
Rolf Bjarne Kvinge 6eabd3aece
[tests] Update known failures for cecil tests after a merge race. (#20480) 2024-04-23 14:40:24 +02:00
Rolf Bjarne Kvinge 45ac791f35
[dotnet] Fix dependencies for Microsoft.<platform>.Sdk.DefaultItems.props. (#20478)
Make sure Microsoft.\<platform\>.Sdk.DefaultItems.props is rebuilt if the
current hash changes.

This fixes a local rebuild issue, where we'd rebuild
Microsoft.\<platform\>.Sdk.Versions.props, but not
Microsoft.\<platform\>.Sdk.DefaultItems.props.

A build failure like this would thus result:

    tools/msbuild/iOS/Xamarin.Shared.targets(606,3): error : A bundle identifier is required. Either add an 'ApplicationId' property in the project file, or add a 'CFBundleIdentifier' entry in the project's Info.plist file.

because:

* We store the current git hash in both of the files mentioned above.
* We only include default items in a build if the git hashes match.
* Since the files weren't both rebuilt, they'd contain different hashes, and
  thus we wouldn't include Info.plist in the build, leading to the build
  error.
2024-04-23 08:08:31 +02:00
Matt Sylvia 9f2a029038
Revert "Update to use System.AccessToken" (#20487)
Reverts xamarin/xamarin-macios#20476

Usage of `System.AccessToken` in this instance fails with `needs Edit
build quality permissions`.
2024-04-23 08:05:13 +02:00
Rolf Bjarne Kvinge f2308d1ed0
[CoreWlan] Make P/Invokes have blittable signatures. (#20465)
Contributes towards #15684.
2024-04-22 18:54:03 +02:00
Rolf Bjarne Kvinge 216ddf7979
[CoreText] Make P/Invokes in CTFontManager have blittable signatures. (#20464)
Contributes towards #15684.
2024-04-22 18:53:52 +02:00
Rolf Bjarne Kvinge 417236e279
[docs] Bring back documentation updates from the documentation repository. (#20453)
It's been a few years since we've synchronized the documentation here with the
documentation in the documentation repository
(https://github.com/MicrosoftDocs/xamarin-docs-pr/), so bring all updates done
there over here.

This PR is probably best reviewed commit-by-commit.
2024-04-22 18:32:21 +02:00
Matt Sylvia 5080f068a6
Update to use System.AccessToken (#20476)
Replace the manually updated PAT `$(pat--xamarinc--build-access)` with
the built in `$(System.AccessToken)`.

This PR is untested but from the documentation I have read it should
work for requesting anything within the same DevOps tenant and project
aka DevDiv.

- [Predefined variables - Azure Pipelines | Microsoft
Learn](https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml)
- [Understand job access tokens - Azure Pipelines | Microsoft
Learn](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/access-tokens?view=azure-devops&tabs=yaml#job-authorization-scope)
2024-04-22 10:46:39 -04:00
Rolf Bjarne Kvinge 4361ccc005
[tools] Add OS check to fix availability warnings. (#20472)
Fixes:

    xamarin-macios/tools/common/PathUtils.cs(297,34): warning CA1416: This call site is reachable on all platforms. 'RegistryKey.GetValue(string?, object?)' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
    xamarin-macios/tools/common/PathUtils.cs(294,32): warning CA1416: This call site is reachable on all platforms. 'RegistryKey.OpenSubKey(string)' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
    xamarin-macios/tools/common/PathUtils.cs(294,32): warning CA1416: This call site is reachable on all platforms. 'Registry.LocalMachine' is only supported on: 'windows'. (https://learn.microsoft.com/dotnet/fundamentals/code-analysis/quality-rules/ca1416)
2024-04-22 14:53:22 +02:00
Rolf Bjarne Kvinge be241769fc
[GameplayKit] Remove the bindings for GKHybridStrategist. (#20468)
The GKHybridStrategist type doesn't exist in iOS. This was probably a type
initially introduced in a beta version, and then removed in a later beta
version, and then we didn't notice.
2024-04-22 07:26:10 +02:00
Rolf Bjarne Kvinge 2d97c8b466
[tools] Create a binlog when building dotnet-linker. (#20473)
Makes diagnosing build issues much easier.
2024-04-22 07:23:57 +02:00
Rolf Bjarne Kvinge c42b4728ba
[tests] Don't verify that obsolete or hidden members have xml documentation. (#20471)
We have enough APIs to document to think about documenting APIs people
shouldn't be using.
2024-04-22 07:23:38 +02:00
Rolf Bjarne Kvinge fcabca0159
[docs] Stop using the term 'Xamarin'. (#20451)
Stop using the term 'Xamarin' in our error messages.

🙈 🙊 🙉

Note: this may not be complete, since we compute error messages in numerous
places, and those aren't fixed here (if there are any that still says
'Xamarin' in any way).

---------

Co-authored-by: Michael Cummings (MSFT) <mcumming@microsoft.com>
2024-04-18 08:41:07 +02:00
Rolf Bjarne Kvinge ee31d72643
[dotnet] Add support for linking with Swift system libraries. Fixes #18848. (#20463)
By adding the 'LinkWithSwiftSystemLibraries=true' property in a project file, we'll
now add the location of Swift's system libraries to the linker arguments.

Fixes https://github.com/xamarin/xamarin-macios/issues/18848.
2024-04-18 08:40:56 +02:00