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

6092 Коммитов

Автор SHA1 Сообщение Дата
Rolf Bjarne Kvinge 6c04f7621a
[tools] Update SdkVersions.cs after the latest Xcode 14.2 bump. (#17101)
* Update `SdkVersions.cs` after the latest Xcode 14.2 bump.
* Rename `[SdkVersions|ProductConstants].cs.in` to `[SdkVersions|ProductConstants].in.cs`.
  This way the autoformatter makes sure it's formatted correctly.
2022-12-21 17:44:27 +01:00
Rolf Bjarne Kvinge e99c71ad36
[tests] Fix a few nullability issues in cecil-tests and the .NET tests. (#17095)
Also make any nullability warnings show up as errors.
2022-12-21 10:19:13 +01:00
Alex Soto a7502b2b8d
[main] Bump bindings to Xcode 14.2 (#17037) 2022-12-21 08:39:03 +01:00
Rolf Bjarne Kvinge 43170cb37e
[tests] Add cecil-test to verify that the obsolete messages are identical between platforms for a given API. (#17089) 2022-12-21 07:44:15 +01:00
Rolf Bjarne Kvinge d9bae59f69
[src/generator/tests] Verify that availability attributes don't include useless version information. Fixes #11029. (#17090)
* Change the generator to not write the version in SupportedOSPlatform
  attributes unless it's greater than min OS version.
* Fix a few redundant Mac Catalyst availability versions.
* Uncomment the test to verify that availability attributes don't include
  useless version information.

Fixes https://github.com/xamarin/xamarin-macios/issues/11029.
2022-12-21 07:44:02 +01:00
Rolf Bjarne Kvinge 83b0727967
[tests] Port and improve the availability attribute test from introspection. (#17083)
Port the availability attribute test from introspection to cecil-tests. It's much
easier and faster to test attributes using Cecil using a desktop executable than
having to execute a test app on each target platform.

This also means that we can make the ApiAvailabilityTest in introspection
legacy-only.

Ref: https://github.com/xamarin/xamarin-macios/issues/10834
2022-12-20 12:46:06 +01:00
Rolf Bjarne Kvinge a227b77402
[generator] tvOS attributes aren't implied from iOS attributes. (#17057)
This hasn't been a problem until now because we've always had tvOS attributes on
most API, but when bumping min OS versions for .NET 8, we'll also remove a lot of
redundant availability attributes. This would break a case where a type is unavailable
on all platforms except tvOS (but without any tvOS availability attribute), and then
we'd get the (implied) iOS (un)availability attribute.
2022-12-20 07:29:19 +01:00
Rolf Bjarne Kvinge 01123bfb0e
[tests] Fix the AppWithNativeDynamicLibrariesInPackageReference to work when not all platforms are enabled. (#17081) 2022-12-19 18:37:10 +01:00
Rolf Bjarne Kvinge d6cb31402f
[tools] Split tools/common/SdkVersions.cs in two files. (#17067)
We need parts of tools/common/SdkVersions.cs when building tests on Windows.
In order to simplify our Windows-life, we're going to check in the generated
SdkVersions.cs file, that way it won't have to be re-generated on Windows (the
logic is very make-based, and not easily executed on Windows).

However, parts of SdkVersions.cs would change every commit, which would make
the above solution rather annoying. So split out those parts into a new file
(ProductConstants.cs), which is still generated during the build (and not
checked in).
2022-12-16 15:25:53 +01:00
Rolf Bjarne Kvinge e69d361c11
[Foundation] Unify the source code for NSAttributedStringDocumentAttributes. (#17069)
Unify the source code for NSAttributedStringDocumentAttributes between
iOS and maOS.

As a result, we're now exposing a few APIs on macOS that were previously
only exposed on iOS.

This PR might be easier to review commit-by-commit.
2022-12-16 15:23:24 +01:00
Rolf Bjarne Kvinge 574031059d
[tests] Improve the Bug35176 generator test. (#17070)
Make it assert on the exact list of attributes we're expecting. This makes it
much easier to see what changed.
2022-12-16 15:20:06 +01:00
Andoni Morales Alastruey 4cfccff38e
Fix libs reidentification deployed in a subdirectory (#16706)
Dynamic libraries might be deployed in subdirectories such as libclrjit.dylib from the nuget package cefglue.common:
Contents/MonoBundle/CefGlueBrowserProcess/libclrjit.dylib

The library ID for that library should be: @executable_path/../MonoBundle/CefGlueBrowserProcess/libclrjit.dylib

Instead of: @executable_path/../MonoBundle/libclrjit.dylib

Beside the library ID being wrong, when it's combined with the nuget package microsoft.netcore.app.runtime.osx-x64 providing a library with the same name, both uses the same `ReidentifiedPath`, which can cause a failure in the InstallNameTool tasks that are run in parallel operating on the same temporary file.

The following patch uses the `RelativePath` for the tempory file used by `InstallNameTool` so that there are no clashes with other files with the same name deployed in other directories. It also uses the `RelativePath` to create the correct library id: @executable_path/../../Contents/MonoBundle/CefGlueBrowserProcess/libclrjit.dylib

Partially fixes https://github.com/xamarin/xamarin-macios/issues/15173 for this scenario
2022-12-16 09:17:01 +01:00
Rolf Bjarne Kvinge 41a4abe54b [xtro] Update. 2022-12-15 16:35:40 +01:00
Rolf Bjarne Kvinge f06c4f2df1
[tests] Remove ignore due to custom code that's been gone for almost two years. (#17027)
We had custom code with Console.WriteLine for macOS 10.12 for a while, but that was removed here:

a93bcdec34

So there's no need to skip the test that verifies we don't call Console.WriteLine anymore.
2022-12-15 14:28:51 +01:00
Rolf Bjarne Kvinge d52fd8ddc8
[tests] Assert that we don't have any private IntPtr constructors in cecil-tests. (#17055) 2022-12-15 13:13:21 +01:00
Rolf Bjarne Kvinge 1c0f4e9c3c
[Network] Fix constructors in NWPathMonitor. (#16977)
* Call _SetUpdatedSnapshotHandler from the (NativeHandle, bool) constructor,
  this way it's called from all constructors.
* Call the (NativeHandle, bool) constructor from all other constructors to
  ensure a consistent instance.
* Remove the internal (IntPtr) constructor, it's no longer used. This also
  fixes a memory leak, because the (IntPtr) constructor would just create a
  new nw_path_monitor instance instead of using the passed-in handle
  (effectively forgetting about it and leaking it).
2022-12-15 08:03:20 +01:00
Rolf Bjarne Kvinge ffad05b9a3
[tests] Use .NET to build cecil-tests. (#17028)
Use .NET to build cecil-tests, using the appropriate verbosity, and creating a
binlog as well.
2022-12-14 22:35:50 +01:00
Rolf Bjarne Kvinge 4a819741f6
[tests] Parameterize the min OS version in a few mtouch tests. (#17035) 2022-12-14 21:44:36 +01:00
Rolf Bjarne Kvinge e3f549fc7e
[tests] Improve cecil-tests's member filtering API. (#17001)
* Improve these methods to find members inside nested types as well.
* Simplify their implementation somewhat.
* Make the filter method optional to allow enumerating everything.
* Rename these methods to Enumerate* to better express what they do.
* Make them extension methods on AssemblyDefinition to make them more
  discoverable and easier to use.
2022-12-13 17:09:45 +01:00
Rolf Bjarne Kvinge 081505b173
[tests] Improve perf in cecil-tests by only loading assemblies once. (#16997)
Improve perf in cecil-tests by caching loaded assemblies, and thus only
loading them once. The gain isn't all that much - it saves about 3s of ~2m on
my machine, so ~1.5% faster - but it'll be more and more important as we write
more tests. Also the code becomes slightly simpler too.
2022-12-13 09:23:25 +01:00
Rolf Bjarne Kvinge 0ba8d7e0e2
[tests] Fix potential NullReferenceException in cecil-tests. (#16998)
Fixes this compiler warning:

    tests/cecil-tests/MarshalAsTest.cs(91,8): warning CS8602: Dereference of a possibly null reference.
2022-12-12 17:14:29 +01:00
Rolf Bjarne Kvinge 3ff320805b
[tests] Enable nullability for numerous files in the .NET tests. (#16976) 2022-12-12 17:13:02 +01:00
Rolf Bjarne Kvinge 660ff60ad5
[tests] Improve performance a bit in Cecil.Tests.GenericPInvokesTest. (#16999)
Improve performance in Cecil.Tests.GenericPInvokesTest by creating fewer
strings.

This saves about 1m07s seconds on my machine, from 2m10s to 1m03s, so ~52%
faster.
2022-12-12 15:29:47 +01:00
Rolf Bjarne Kvinge dc37be300e
Remove bitcode-related code, since bitcode is dead. (#16986) 2022-12-12 15:25:37 +01:00
Rolf Bjarne Kvinge cc5c1bb4bf
[tests] Adjust cecil-tests to not test 32-bit iOS assemblies unless 32-bit iOS architectures are enabled. (#16989) 2022-12-07 18:24:14 +01:00
Rolf Bjarne Kvinge d17191f9c3
[xharness] Parameterize the min OS version for generated projects. (#16985) 2022-12-07 17:43:52 +01:00
Rolf Bjarne Kvinge cb28b21189
[tools/src] Enable nullability in a few error-related source files. (#16987) 2022-12-07 17:43:05 +01:00
Rolf Bjarne Kvinge 78813cb591
[tests] Remove some dead code. (#16988) 2022-12-07 17:42:36 +01:00
Rolf Bjarne Kvinge 7f2d7dcce5
[tests] We don't want exceptions to the obsolete test to apply anymore in XAMCORE_5_0 in cecil-tests. (#16991)
That's the time to fix those exceptions.
2022-12-07 17:42:11 +01:00
Rolf Bjarne Kvinge 25fc6c84d1
[dotnet-linker] Handle null fields in BackingFieldDelayHandler as unmarked fields. Fixes #16957. (#16970)
The BackingFieldDelayHandler will temporarily remove the body of Dispose
methods, and then for every field accessed in the Dispose method that was
preserved by the linker, we'll keep the corresponding code in the Dispose
method (otherwise we'd remove the code).

This is a way to remove fields that are _only_ accessed (and nulled out) in
the Dispose method.

However, we were running into a problem with determining if a field was marked
by the linker: if the field is in a generic type, and that field was not
marked by the linker, the linker might have actually removed the field from
the containing type before we're processing the Dispose methods, and we'd find
a null field definition where no null field definition was expected
(eventually resulting in an ArgumentNullException).

Fix this by treating a null field definition as an unmarked field.

Also add a test.

Fixes https://github.com/xamarin/xamarin-macios/issues/16957.
2022-12-07 15:53:15 +01:00
Rolf Bjarne Kvinge 6581fcb5fb
[Foundation] Create a new NSAttributedStringDocumentAttributeKey enum to match Apple's headers. (#16969)
This allows us to unify the code between all platforms.

Also add all the NSAttributedStringDocumentAttributeKey values we haven't bound yet.

There are no changes in the public API, because I'm only changing internal types.

Ref: #14489.
2022-12-07 15:52:20 +01:00
Steve Hawley 3c512a8331
[net8.0] added a test for blittability of pinvokes, partial #15684 (#16525)
This adds a unit test to check for blittability of arguments to
pinvokes.
2022-12-06 14:35:16 -05:00
Rolf Bjarne Kvinge 407b4c4ac6
[tests] Add logic to detect when macOS and Mac Catalyst test apps don't launch properly. Fixes #xamarin/maccore@2414. (#16946)
Implement a launch timeout for macOS and Mac Catalyst apps where if a certain
environment variable (LAUNCH_SENTINEL_FILE) is set, the app will create that
file at launch. The code launching the test app will wait 10 seconds and check
if the file is there: if it's not, something went wrong, in which case the app
should be terminated and launched again.

This necessitated re-implementing the launch script in C#, since it got quite
complicated to implement in bash.

This fixes an issue with Mac Catalyst apps where something would go wrong
during the app launch and nothing would happen (but the app wouldn't be
deadlocked, it would just sit there, doing nothing).

The TestRuntime.cs and ApplePlatform.cs had to be added to a few test projects
to make this compile, which required a few fixes in these files for building
with legacy Xamarin.Mac.

Fixes https://github.com/xamarin/maccore/issues/2414.
2022-12-06 13:11:36 +01:00
Rolf Bjarne Kvinge 94bdee0d7c
[autoformat] Update some new code. (#16967)
This is code from PRs that were started before we started autoformatting
the files in question, and then merged afterwards.
2022-12-06 07:49:52 +01:00
Rolf Bjarne Kvinge 36125e3b3f
[tests] Ignore the MonoTests.System.TimeZoneInfoTest+IsDaylightSavingTimeTests.Bug_16395 test. Fixes #xamarin/maccore@2629. (#16956)
It looks like some timezone data has changed, so this test is now failing.
Mono will probably not be updated, so just ignore the test.

Fixes https://github.com/xamarin/maccore/issues/2629.
2022-12-05 22:31:16 +01:00
Rolf Bjarne Kvinge b3cb85c0ad
[tests] Allow for timeouts in CI in a few tests. (#16945)
Also add some exception handling.

Hopefully fixes more issues with broken network in CI.
2022-12-05 08:53:33 +01:00
Rolf Bjarne Kvinge f7533f5ab9
Bump xharness. (#16947) 2022-12-05 08:53:05 +01:00
Rolf Bjarne Kvinge 1c80823582
[autoformat] Add all of tests/. (#16857) 2022-12-05 08:23:34 +01:00
Rolf Bjarne Kvinge 084f056855
[tests] Enable nullability in tests/common/DotNet.cs. (#16927) 2022-12-01 21:57:36 +01:00
Haritha Mohan 1dc6cacafb
[UIKit] Add GetWeight method for UIFontWeight (#16922)
Made UIFontWeightConstants visible and added an extensions method to
access font weights easily.
Also added test to ensure GetWeight works as expected. 
Fixes #10753

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
2022-12-01 11:02:24 -08:00
Rolf Bjarne Kvinge 786346cf0c
[autoformat] Update some new code. (#16921)
This is code from PRs that were started before we started autoformatting the
files in question, and then merged afterwards.
2022-12-01 08:31:34 +01:00
Rolf Bjarne Kvinge 7b2b1c746c
[xharness] Packaged macOS tests are a thing now. (#16905)
While this value isn't used directly in xharness, we can add a
'skip-packaged-macos-tests' label for a PR, which xharness will try to match
with a test label, so the test label must exist, otherwise all tests will
fail.
2022-11-29 21:47:30 +01:00
Haritha Mohan 64bb06c71d
[src] use HashCode.Combine to generate hashcodes (#16841)
Fixes #16677

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
Co-authored-by: TJ Lambert <50846373+tj-devel709@users.noreply.github.com>
Co-authored-by: TJ Lambert <tjlambert@microsoft.com>
Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: GitHub Actions <github-actions@xamarin.com>
Co-authored-by: Rolf Bjarne Kvinge <rolf@xamarin.com>
Co-authored-by: VS MobileTools Engineering Service 2 <vsmobiletoolsengsvc2@microsoft.com>
2022-11-29 10:43:46 -08:00
Haritha Mohan 5a0366a9fa
[Foundation] Add missing bindings in NSTask (#16856)
Added new bindings for deprecated methods/properties: 

Launch -> LaunchAndReturnError
LaunchFromPath -> LaunchFromUrl
LaunchPath -> ExecutableUrl
CurrentDirectoryPath -> CurrentDirectoryUrl

Fixes #14659
2022-11-29 08:32:36 -08:00
Rolf Bjarne Kvinge eed66a2e21
[tests] Use CFString.FromHandle instead of NSString.FromHandle. (#16874)
Fixes this warning:

> warning CS0618: 'NSString.FromHandle(NativeHandle)' is obsolete: 'Use of 'CFString.FromHandle' offers better performance.'
2022-11-29 09:30:17 +01:00
Rolf Bjarne Kvinge 053078c167
[tests] Ignore CA1422 for some code. (#16875)
Fixes these warnings:

    xamarin-macios/tests/common/TestRuntime.cs(1228,8): warning CA1422: This call site is reachable on: 'MacCatalyst' 13.3 and later. 'ABAuthorizationStatus.Denied' is obsoleted on: 'maccatalyst' 9.0 and later (Use the 'Contacts' API instead.).
    xamarin-macios/tests/common/TestRuntime.cs(1227,8): warning CA1422: This call site is reachable on: 'MacCatalyst' 13.3 and later. 'ABAuthorizationStatus.Restricted' is obsoleted on: 'maccatalyst' 9.0 and later (Use the 'Contacts' API instead.).
    xamarin-macios/tests/common/TestRuntime.cs(1221,8): warning CA1422: This call site is reachable on: 'MacCatalyst' 13.3 and later. 'ABAuthorizationStatus.NotDetermined' is obsoleted on: 'maccatalyst' 9.0 and later (Use the 'Contacts' API instead.).
2022-11-29 09:29:59 +01:00
Rolf Bjarne Kvinge cbfcabacf6
[msbuild] Fix parsing -gcc_flags when the value is the next argument. Fixes #16861. (#16862)
The -gcc_flags in the extra mtouch/mmp arguments can either be of the format
'-gcc_flags=<value>' or '-gcc_flags <value>'. Previously we only parsed the
former correctly, and now fix the parsing logic to handle the latter version
correctly as well.

Fixes https://github.com/xamarin/xamarin-macios/issues/16861.
2022-11-29 09:29:27 +01:00
Haritha Mohan 51afd316cc
[tests] Ensure proper capitalization in API (#16840)
Use reflection to detect incorrectly capitalized public methods, fields,
properties, and events.
Fixes #15733

Co-authored-by: GitHub Actions Autoformatter <github-actions-autoformatter@xamarin.com>
Co-authored-by: Manuel de la Pena <mandel@microsoft.com>
2022-11-28 12:11:27 -08:00
Rolf Bjarne Kvinge ff585dca2d
[tests] Move code to avoid unreachable code warning. (#16876)
Fixes this warning:

> xamarin-macios/tests/common/TestRuntime.cs(1321,4): warning CS0162: Unreachable code detected
2022-11-28 18:18:11 +01:00
Rolf Bjarne Kvinge d627b203eb
[tests] Create a shared AppDelegate class and use it everywhere. (#16877)
Create a shared AppDelegate class, which contains all the identical
AppDelegate code for all test projects. This reduces a lot of code duplication.
2022-11-28 18:17:49 +01:00