Skip to content

Removal of platform preprocessor blocks in binding definations #14444

Closed

Description

@chamons

Context

We have a large number of bindings that do this:

#if !MONOMAC
[iOS (7,0)]
[Field ("AVCaptureSessionPresetInputPriority")]
NSString PresetInputPriority { get; }
#endif

Conditionally removing parts (or entire classes) out using the preprocessor. This works grand in legacy, but in NET6 there is a problem:

  • Since there is one attribute, iOS, we must declare every other one.
  • Since there is no mac one, and we are in a mac friendly file, the generator adds a mac without a version.
  • My new attribute test then screams "You said this thing exists on mac but it doesn't, liar!".

In the "modern" binding style we instead use attributes such as [NoiOS] and define tricks like using NSCell=System.Object; instead of defines.

Task

  • Choose an available framework. Edit this description and post your name next to the framework in question:
    image
  • Open the primary definition file (appkit.cs for example) and search for #if
  • If it both:
    • A platform define we care about in NET6 (MONOMAC, IOS, etc) and NOT NET/!NET/WATCH
    • The block conditionally compiled contains actual binding interfaces/enums/etc
  • Then remove the block, apply the relevant availability attribute ([NoiOS], [NoMac], etc) to the attributes.
  • Once you process the entire file, try compiling src and see what (if anything breaks). You may need to use using tricks if the blocks contains type like UIView or NSView for example.
  • Due to conditionally compiled types, some rare cases #if can't be removed reasonably. In that case keep it and add [NoiOS], [NoMac], and so on to every member that has an existing type attribute.
  • Once src builds, run introspection and xtro locally
  • Check the diff one last time, then, and only then PR the specific framework
  • Edit this description and post a link to your PR next to the framework in question
  • Then check the box once the PR lands.

Punchlist

Moved to an internal document due to GH issue issues.

Activity

  1. added this to the Future milestone on Mar 17, 2022
  2. added
    not-notes-worthy
    on Mar 17, 2022
  3. rolfbjarne commented on Mar 21, 2022

    @rolfbjarne
    Member

    We should really have xtro working again before merging any of these PRs, since xtro will catch some mistakes.

  4. chamons commented on Apr 4, 2022

    @chamons
    ContributorAuthor

    All done!

  5. ghost locked as resolved and limited conversation to collaborators on May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    not-notes-worthy

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions