xamarin-macios/tests/introspection
Sebastien Pouliot 98b8ac8321
[tests] Add `.cctor` execution to introspection (#7976)
This will spot cases like https://github.com/xamarin/xamarin-macios/issues/7959
where a type (static) constructor can fail at runtime, leading to
`TypeLoadException`

Ideally it's covered by it's own tests but it's better covered twice
than never :)

On iOS 64bits [1] simulator we hit some failures [2], later, if the
`.cctor` is executed. It's not a big deal to avoid those types since
we it will be executed on devices later.

[1] API not present on 32bits

[2] Fixing the following triggers similar failures for `DCDevice`

```
ApiClassPtrTest.VerifyClassPtr: class_ptr and RegisterAttribute are different: NFCIso15693CustomCommandConfiguration
Expected: 0
But was: 140735471513712

ApiSelectorTest.StaticMethods: 7 errors found in 2788 static selector validated:
CoreNFC.NFCIso15693ReaderSession : readingAvailable
CoreNFC.NFCNdefMessage : ndefMessageWithData:
CoreNFC.NFCNdefPayload : wellKnownTypeURIPayloadWithString:
CoreNFC.NFCNdefPayload : wellKnownTypeURIPayloadWithURL:
CoreNFC.NFCNdefPayload : wellKnownTypeTextPayloadWithString:locale:
CoreNFC.NFCNdefReaderSession : readingAvailable
CoreNFC.NFCReaderSession : readingAvailable
Expected: 0
But was: 7
```
2020-02-26 15:03:59 -05:00
..
Mac [tests] Add `.cctor` execution to introspection (#7976) 2020-02-26 15:03:59 -05:00
iOS [tests] Add `.cctor` execution to introspection (#7976) 2020-02-26 15:03:59 -05:00
ApiAvailabilityTest.cs [Introspection] Add Mac OS X 15.15.1 on availability tests. (#7328) 2019-10-30 01:47:41 -04:00
ApiBaseTest.cs [PDFKit] Update bindings to Xcode 10 Beta 1, 2 & 3 (#4439) 2018-07-13 14:14:05 -05:00
ApiCMAttachmentTest.cs Merge branch 'xcode11.2' into master-merge-xcode11.2 2019-11-05 15:25:49 -05:00
ApiClassPtrTest.cs Move parts of dontlink tests into new introspection tests (#32) 2016-05-04 20:14:32 -04:00
ApiCoreImageFiltersTest.cs [CoreImage] Fix a couple of test/availability issues. (#7259) 2019-10-18 22:42:12 +02:00
ApiCtorInitTest.cs [Appkit] Bindings part 4 (#7295) 2019-10-28 15:38:34 -04:00
ApiFieldTest.cs [xcode11] Remove the WatchKit framework from iOS while keeping API stability. Fixes #6492. (#6503) 2019-08-14 17:46:55 +02:00
ApiFrameworkTest.cs [Localization] mtouch/mmp C# (#7710) 2020-01-31 15:02:52 -05:00
ApiPInvokeTest.cs Merge branch 'master' into mono-2018-10 2019-02-05 21:38:47 +01:00
ApiProtocolTest.cs Fix a few introspection issues on Catalina. (#7212) (#7243) 2019-10-22 22:30:19 +02:00
ApiSelectorTest.cs [MapKit] Update for new API Xcode11 b1 - b7 (#6934) 2019-09-11 09:56:10 -04:00
ApiSignatureTest.cs Merge xcode9 into d15-4[-xi] (#2710) 2017-09-15 17:53:16 -04:00
ApiStructTest.cs Move parts of dontlink tests into new introspection tests (#32) 2016-05-04 20:14:32 -04:00
ApiTypeTest.cs [tests] Add `.cctor` execution to introspection (#7976) 2020-02-26 15:03:59 -05:00
ApiTypoTest.cs [Localization] mtouch/mmp C# (#7710) 2020-01-31 15:02:52 -05:00
ApiWeakPropertyTest.cs [homekit] Expose weakly-typed API since the constants are extensible. Fixed #60303 (#3025) 2017-11-21 20:50:33 -05:00
CoreSelectorTest.cs [macos] Fix introspection tests (typo + NSUrlSession* test sharing) 2016-09-06 13:32:51 -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