xamarin-macios/tests/introspection
Chris Hamons 1dcefc9c56
[NET Attribute Conversion][generator] Generate NET style attributes (#14779)
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>
2022-05-02 09:44:25 -05:00
..
Mac [src/introspection] Adjust tests and availability attributes to work run on iOS/tvOS 12.4. Fixes #13957. (#14133) 2022-02-15 08:20:16 +01:00
dotnet [tests] Use 'BundledNETCoreAppTargetFrameworkVersion' to specify the .NET version in the project files. (#14666) 2022-04-06 20:58:20 +02:00
iOS [src/introspection] Adjust tests and availability attributes to work run on iOS/tvOS 12.4. Fixes #13957. (#14133) 2022-02-15 08:20:16 +01:00
ApiAvailabilityTest.cs [NET Attribute Conversion][generator] Generate NET style attributes (#14779) 2022-05-02 09:44:25 -05:00
ApiBaseTest.cs [tests][intro] Fix Phase tests on macOS 12 and iOS devices (#12376) 2021-08-06 16:28:04 -04:00
ApiCMAttachmentTest.cs [introspection] Fix ApiCMAttachmentTest on macOS / Mac Catalyst. (#14266) 2022-02-28 22:35:42 +01:00
ApiClassPtrTest.cs [tests][introspection] A few test updates according to the API changes 2021-11-26 14:25:21 +01:00
ApiCoreImageFiltersTest.cs [CoreImage] Adopt XAMCORE_4_0 changes in .NET. (#13983) 2022-02-02 16:07:45 +01:00
ApiCtorInitTest.cs [tools] HomeKit was added to Mac Catalyst in 14.0, so mark it as such. (#13333) 2021-11-15 08:04:56 +01:00
ApiFieldTest.cs [xcode13] Bump PR to Xcode 13 Beta 2 (#12017) 2021-06-28 17:54:52 -04:00
ApiFrameworkTest.cs [Foundation] Remove a WebKit workaround for NSProxy on tvOS in .NET. (#14089) 2022-02-08 10:48:40 +01:00
ApiPInvokeTest.cs [introspection] Skip verifying the objc_msgSend[Super]_stret on all platforms. (#12939) 2021-10-07 20:15:54 +02:00
ApiProtocolTest.cs [HomeKit] Update bindings up to Xcode 13.3 Beta 3 2022-03-14 22:54:34 -04:00
ApiSelectorTest.cs [ScreenCaptureKit] Add ScreenCaptureKit bindings up to Xcode 13.3 (#14644) 2022-04-05 20:16:31 -04:00
ApiSignatureTest.cs [runtime] Remove ObjCRuntime.nfloat in favor of System.Runtime.InteropServices.NFloat. (#14197) 2022-02-24 16:51:12 +01:00
ApiStructTest.cs Fix some whitespace issues in various files. (#12399) 2021-08-11 10:06:46 +02:00
ApiTypeTest.cs [dotnet] Remove Runtime.Arch and ObjCRuntime.Arch from Mac Catalyst. Fixes #10312. (#13562) 2021-12-15 22:32:14 +01:00
ApiTypoTest.cs [tests] Adopt XAMCORE_4_0 changes for introspection in .NET. (#14098) 2022-02-09 08:26:37 +01:00
ApiWeakPropertyTest.cs Fix some whitespace issues in various files. (#12399) 2021-08-11 10:06:46 +02:00
CoreSelectorTest.cs [xcode12] Introspection-based fixes for Big Sur (#9632) 2020-09-15 08:56:24 -04:00
EnvironmentVariable.cs Move parts of dontlink tests into new introspection tests (#32) 2016-05-04 20:14:32 -04:00
README.md [tests] Move linker tests from maccore (#69) 2016-05-20 14:07:34 -04:00
xamarin1.png Move parts of dontlink tests into new introspection tests (#32) 2016-05-04 20:14:32 -04:00

README.md

Introspection Tests

Introspection tests are executed on target (both simulator and device for iOS) or a specific version of OSX. The application proceed to analyze itself using:

  • System.Reflection for managed code; and
  • the ObjectiveC runtime library for native code

and compare the results. E.g. if using .NET reflection it can see a binding for a NSBundle type then it should be able to find a native NSBundle type using the ObjC runtime functions. Otherwise an error is raised...

Since the application analyze itself it must contains everything we wish to test. That's why the introspection tests needs to be built with the managed linker disable, i.e. "Don't link".

Pros

  • The tests always tell the truth, which can differ from documentation or header files;

Cons

  • Incomplete - Not everything is encoded in the metadata / executable;
  • Too complete - Not every truth is good to be known (or published), which requires creating special cases in the tests